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
set_legislation_proposal_votes(@process.proposals)
@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),
status: :moved_permanently if request.path != legislation_process_proposal_path(params[:process_id], @proposal)
status: :moved_permanently
end
end
def create
@@ -52,7 +54,7 @@ class Legislation::ProposalsController < Legislation::BaseController
params.require(:legislation_proposal).permit(:legislation_process_id, :title,
:question, :summary, :description, :video_url, :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 resource_model

View File

@@ -29,7 +29,7 @@ module AdminHelper
end
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
def menu_banners?

View File

@@ -57,8 +57,7 @@ class Legislation::Proposal < ActiveRecord::Base
tag_list.join(' ') => 'B',
geozone.try(:name) => 'B',
summary => 'C',
description => 'D'
}
description => 'D'}
end
def self.search(terms)
@@ -69,7 +68,7 @@ class Legislation::Proposal < ActiveRecord::Base
def self.search_by_code(terms)
matched_code = match_code(terms)
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
def self.match_code(terms)
@@ -105,9 +104,7 @@ class Legislation::Proposal < ActiveRecord::Base
end
def register_vote(user, vote_value)
if votable_by?(user)
vote_by(voter: user, vote: vote_value)
end
vote_by(voter: user, vote: vote_value) if votable_by?(user)
end
def code

View File

@@ -37,7 +37,7 @@ class Poll::Question::Answer < ActiveRecord::Base
end
def most_voted?
self.most_voted
most_voted
end
def total_votes_percentage
@@ -47,8 +47,8 @@ class Poll::Question::Answer < ActiveRecord::Base
def set_most_voted
answers = question.question_answers
.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

View File

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

View File

@@ -102,7 +102,6 @@ class User < ActiveRecord::Base
voted.each_with_object({}) { |v, h| h[v.votable_id] = v.value }
end
def spending_proposal_votes(spending_proposals)
voted = votes.for_spending_proposals(spending_proposals)
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_annotation) { create(:legislation_annotation, author: author) }
let(:topic) {
let(:topic) do
proposal = create(:proposal)
community = proposal.community
create(:topic, community: community, author: author)
}
end
scenario "User commented on my debate", :js do
create(:notification, notifiable: debate, user: author)

View File

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