Apply Style/CollectionMethods rubocop rule
We were already using `map` and `reduce` almost everywhere.
This commit is contained in:
@@ -379,6 +379,9 @@ Style/ClassCheck:
|
|||||||
Style/ClassVars:
|
Style/ClassVars:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
Style/CollectionMethods:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
Style/Not:
|
Style/Not:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
|||||||
@@ -80,9 +80,9 @@ class Admin::StatsController < Admin::BaseController
|
|||||||
|
|
||||||
@vote_count = @budget.lines.count
|
@vote_count = @budget.lines.count
|
||||||
|
|
||||||
@vote_count_by_heading = @budget.lines.group(:heading_id).count.collect { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
@vote_count_by_heading = @budget.lines.group(:heading_id).count.map { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
||||||
|
|
||||||
@user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.collect { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
@user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.map { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def polls
|
def polls
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module Dashboard::GroupSupports
|
|||||||
|
|
||||||
def accumulate_supports(grouped_votes)
|
def accumulate_supports(grouped_votes)
|
||||||
grouped_votes.each do |group, votes|
|
grouped_votes.each do |group, votes|
|
||||||
grouped_votes[group] = votes.inject(0) { |sum, vote| sum + vote.vote_weight }
|
grouped_votes[group] = votes.reduce(0) { |sum, vote| sum + vote.vote_weight }
|
||||||
end
|
end
|
||||||
|
|
||||||
accumulated = 0
|
accumulated = 0
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ module RemotelyTranslatable
|
|||||||
end
|
end
|
||||||
|
|
||||||
def resources_groups(*args)
|
def resources_groups(*args)
|
||||||
feeds = args.detect { |arg| arg&.first.class == Widget::Feed } || []
|
feeds = args.find { |arg| arg&.first.class == Widget::Feed } || []
|
||||||
|
|
||||||
args.compact - [feeds] + feeds.map(&:items)
|
args.compact - [feeds] + feeds.map(&:items)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class Tracking::BudgetInvestmentsController < Tracking::BaseController
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
investment_headings.inject(all_headings_filter) do |filters, heading|
|
investment_headings.reduce(all_headings_filter) do |filters, heading|
|
||||||
filters << {
|
filters << {
|
||||||
name: heading.name,
|
name: heading.name,
|
||||||
id: heading.id,
|
id: heading.id,
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
investment_headings.inject(all_headings_filter) do |filters, heading|
|
investment_headings.reduce(all_headings_filter) do |filters, heading|
|
||||||
filters << {
|
filters << {
|
||||||
name: heading.name,
|
name: heading.name,
|
||||||
id: heading.id,
|
id: heading.id,
|
||||||
|
|||||||
@@ -83,9 +83,7 @@ module AdminHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def admin_select_options
|
def admin_select_options
|
||||||
Administrator.with_user
|
Administrator.with_user.map { |v| [v.description_or_name, v.id] }.sort_by { |a| a[0] }
|
||||||
.collect { |v| [v.description_or_name, v.id] }
|
|
||||||
.sort_by { |a| a[0] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def admin_submit_action(resource)
|
def admin_submit_action(resource)
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ module GeozonesHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def geozone_select_options
|
def geozone_select_options
|
||||||
Geozone.all.order(name: :asc).collect { |g| [g.name, g.id] }
|
Geozone.all.order(name: :asc).map { |g| [g.name, g.id] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module PollsHelper
|
module PollsHelper
|
||||||
def poll_select_options(include_all = nil)
|
def poll_select_options(include_all = nil)
|
||||||
options = @polls.collect do |poll|
|
options = @polls.map do |poll|
|
||||||
[poll.name, current_path_with_query_params(poll_id: poll.id)]
|
[poll.name, current_path_with_query_params(poll_id: poll.id)]
|
||||||
end
|
end
|
||||||
options << all_polls if include_all
|
options << all_polls if include_all
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module ProposalsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def retire_proposals_options
|
def retire_proposals_options
|
||||||
Proposal::RETIRE_OPTIONS.collect { |option| [t("proposals.retire_options.#{option}"), option] }
|
Proposal::RETIRE_OPTIONS.map { |option| [t("proposals.retire_options.#{option}"), option] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def empty_recommended_proposals_message_text(user)
|
def empty_recommended_proposals_message_text(user)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module ShiftsHelper
|
|||||||
def shift_recount_scrutiny_dates(booth, polls)
|
def shift_recount_scrutiny_dates(booth, polls)
|
||||||
return [] if polls.blank?
|
return [] if polls.blank?
|
||||||
|
|
||||||
dates = polls.map(&:ends_at).map(&:to_date).sort.inject([]) do |total, date|
|
dates = polls.map(&:ends_at).map(&:to_date).sort.reduce([]) do |total, date|
|
||||||
initial_date = date < Date.current ? Date.current : date
|
initial_date = date < Date.current ? Date.current : date
|
||||||
total << (initial_date..date + Poll::RECOUNT_DURATION).to_a
|
total << (initial_date..date + Poll::RECOUNT_DURATION).to_a
|
||||||
end
|
end
|
||||||
@@ -33,7 +33,7 @@ module ShiftsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def officer_select_options(officers)
|
def officer_select_options(officers)
|
||||||
officers.collect { |officer| [officer.name, officer.id] }
|
officers.map { |officer| [officer.name, officer.id] }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ module TranslatableFormHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def existing_translation_for(locale)
|
def existing_translation_for(locale)
|
||||||
@object.translations.detect { |translation| translation.locale == locale }
|
@object.translations.find { |translation| translation.locale == locale }
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_translation_for(locale)
|
def new_translation_for(locale)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module UserSegmentsHelper
|
module UserSegmentsHelper
|
||||||
def user_segments_options
|
def user_segments_options
|
||||||
UserSegments::SEGMENTS.collect do |user_segment_name|
|
UserSegments::SEGMENTS.map do |user_segment_name|
|
||||||
[t("admin.segment_recipient.#{user_segment_name}"), user_segment_name]
|
[t("admin.segment_recipient.#{user_segment_name}"), user_segment_name]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ module ValuationHelper
|
|||||||
|
|
||||||
def valuator_select_options
|
def valuator_select_options
|
||||||
Valuator.order("description ASC").order("users.email ASC").includes(:user).
|
Valuator.order("description ASC").order("users.email ASC").includes(:user).
|
||||||
collect { |v| [v.description_or_email, "valuator_#{v.id}"] }
|
map { |v| [v.description_or_email, "valuator_#{v.id}"] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def valuator_group_select_options
|
def valuator_group_select_options
|
||||||
ValuatorGroup.order("name ASC").collect { |g| [g.name, "group_#{g.id}"] }
|
ValuatorGroup.order("name ASC").map { |g| [g.name, "group_#{g.id}"] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def explanation_field(field)
|
def explanation_field(field)
|
||||||
|
|||||||
@@ -376,11 +376,11 @@ class Budget
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assigned_valuators
|
def assigned_valuators
|
||||||
self.valuators.collect(&:description_or_name).compact.join(", ").presence
|
self.valuators.map(&:description_or_name).compact.join(", ").presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def assigned_valuation_groups
|
def assigned_valuation_groups
|
||||||
self.valuator_groups.collect(&:name).compact.join(", ").presence
|
self.valuator_groups.map(&:name).compact.join(", ").presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def valuation_tag_list
|
def valuation_tag_list
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class Budget::Stats
|
|||||||
end
|
end
|
||||||
|
|
||||||
def total_votes
|
def total_votes
|
||||||
budget.ballots.pluck(:ballot_lines_count).inject(0) { |sum, x| sum + x }
|
budget.ballots.pluck(:ballot_lines_count).reduce(0) { |sum, x| sum + x }
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_selected_investments
|
def total_selected_investments
|
||||||
@@ -72,18 +72,18 @@ class Budget::Stats
|
|||||||
end
|
end
|
||||||
|
|
||||||
groups[:total] = Hash.new(0)
|
groups[:total] = Hash.new(0)
|
||||||
groups[:total][:total_investments_count] = groups.collect { |_k, v| v[:total_investments_count] }.sum
|
groups[:total][:total_investments_count] = groups.map { |_k, v| v[:total_investments_count] }.sum
|
||||||
groups[:total][:total_participants_support_phase] = groups.collect { |_k, v| v[:total_participants_support_phase] }.sum
|
groups[:total][:total_participants_support_phase] = groups.map { |_k, v| v[:total_participants_support_phase] }.sum
|
||||||
groups[:total][:total_participants_vote_phase] = groups.collect { |_k, v| v[:total_participants_vote_phase] }.sum
|
groups[:total][:total_participants_vote_phase] = groups.map { |_k, v| v[:total_participants_vote_phase] }.sum
|
||||||
groups[:total][:total_participants_every_phase] = groups.collect { |_k, v| v[:total_participants_every_phase] }.sum
|
groups[:total][:total_participants_every_phase] = groups.map { |_k, v| v[:total_participants_every_phase] }.sum
|
||||||
|
|
||||||
budget.headings.each do |heading|
|
budget.headings.each do |heading|
|
||||||
groups[heading.id].merge!(calculate_heading_stats_with_totals(groups[heading.id], groups[:total], heading.population))
|
groups[heading.id].merge!(calculate_heading_stats_with_totals(groups[heading.id], groups[:total], heading.population))
|
||||||
end
|
end
|
||||||
|
|
||||||
groups[:total][:percentage_participants_support_phase] = groups.collect { |_k, v| v[:percentage_participants_support_phase] }.sum
|
groups[:total][:percentage_participants_support_phase] = groups.map { |_k, v| v[:percentage_participants_support_phase] }.sum
|
||||||
groups[:total][:percentage_participants_vote_phase] = groups.collect { |_k, v| v[:percentage_participants_vote_phase] }.sum
|
groups[:total][:percentage_participants_vote_phase] = groups.map { |_k, v| v[:percentage_participants_vote_phase] }.sum
|
||||||
groups[:total][:percentage_participants_every_phase] = groups.collect { |_k, v| v[:percentage_participants_every_phase] }.sum
|
groups[:total][:percentage_participants_every_phase] = groups.map { |_k, v| v[:percentage_participants_every_phase] }.sum
|
||||||
|
|
||||||
groups
|
groups
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module SearchCache
|
|||||||
def searchable_values_sql
|
def searchable_values_sql
|
||||||
searchable_values
|
searchable_values
|
||||||
.select { |k, _| k.present? }
|
.select { |k, _| k.present? }
|
||||||
.collect { |value, weight| set_tsvector(value, weight) }
|
.map { |value, weight| set_tsvector(value, weight) }
|
||||||
.join(" || ")
|
.join(" || ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class Poll::Question < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def answers_total_votes
|
def answers_total_votes
|
||||||
question_answers.visibles.inject(0) { |total, question_answer| total + question_answer.total_votes }
|
question_answers.visibles.reduce(0) { |total, question_answer| total + question_answer.total_votes }
|
||||||
end
|
end
|
||||||
|
|
||||||
def most_voted_answer_id
|
def most_voted_answer_id
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class Signature < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def in_census?
|
def in_census?
|
||||||
document_types.detect do |document_type|
|
document_types.find do |document_type|
|
||||||
response = CensusCaller.new.call(document_type, document_number, date_of_birth, postal_code)
|
response = CensusCaller.new.call(document_type, document_number, date_of_birth, postal_code)
|
||||||
if response.valid?
|
if response.valid?
|
||||||
@census_api_response = response
|
@census_api_response = response
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class SignatureSheet < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parsed_required_fields_to_verify_groups
|
def parsed_required_fields_to_verify_groups
|
||||||
required_fields_to_verify.split(/[;]/).collect { |d| d.gsub(/\s+/, "") }.map { |group| group.split(/[,]/) }
|
required_fields_to_verify.split(/[;]/).map { |d| d.gsub(/\s+/, "") }.map { |group| group.split(/[,]/) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def signable_found
|
def signable_found
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Widget::Feed < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.active
|
def self.active
|
||||||
KINDS.collect do |kind|
|
KINDS.map do |kind|
|
||||||
feed = find_or_create_by!(kind: kind)
|
feed = find_or_create_by!(kind: kind)
|
||||||
feed if feed.active?
|
feed if feed.active?
|
||||||
end.compact
|
end.compact
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ unless defined?(Spring)
|
|||||||
require "bundler"
|
require "bundler"
|
||||||
|
|
||||||
lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
|
lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
|
||||||
spring = lockfile.specs.detect { |spec| spec.name == "spring" }
|
spring = lockfile.specs.find { |spec| spec.name == "spring" }
|
||||||
if spring
|
if spring
|
||||||
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
|
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
|
||||||
gem "spring", spring.version
|
gem "spring", spring.version
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ namespace :proposal_actions do
|
|||||||
5
|
5
|
||||||
]
|
]
|
||||||
|
|
||||||
votes_count = expected_supports.inject(0.0) { |sum, x| sum + x }
|
votes_count = expected_supports.reduce(0.0) { |sum, x| sum + x }
|
||||||
goal_votes = Setting["votes_for_proposal_success"].to_f
|
goal_votes = Setting["votes_for_proposal_success"].to_f
|
||||||
cached_votes_up = 0
|
cached_votes_up = 0
|
||||||
|
|
||||||
|
|||||||
@@ -632,11 +632,11 @@ describe "Budget Investments" do
|
|||||||
visit budget_investments_path(budget, heading_id: heading.id)
|
visit budget_investments_path(budget, heading_id: heading.id)
|
||||||
|
|
||||||
within(".submenu .is-active") { expect(page).to have_content "random" }
|
within(".submenu .is-active") { expect(page).to have_content "random" }
|
||||||
order = all(".budget-investment h3").collect { |i| i.text }
|
order = all(".budget-investment h3").map { |i| i.text }
|
||||||
expect(order).not_to be_empty
|
expect(order).not_to be_empty
|
||||||
|
|
||||||
visit budget_investments_path(budget, heading_id: heading.id)
|
visit budget_investments_path(budget, heading_id: heading.id)
|
||||||
new_order = all(".budget-investment h3").collect { |i| i.text }
|
new_order = all(".budget-investment h3").map { |i| i.text }
|
||||||
|
|
||||||
expect(order).to eq(new_order)
|
expect(order).to eq(new_order)
|
||||||
end
|
end
|
||||||
@@ -645,14 +645,14 @@ describe "Budget Investments" do
|
|||||||
(per_page + 2).times { create(:budget_investment, heading: heading) }
|
(per_page + 2).times { create(:budget_investment, heading: heading) }
|
||||||
|
|
||||||
visit budget_investments_path(budget, heading_id: heading.id)
|
visit budget_investments_path(budget, heading_id: heading.id)
|
||||||
order = all(".budget-investment h3").collect { |i| i.text }
|
order = all(".budget-investment h3").map { |i| i.text }
|
||||||
expect(order).not_to be_empty
|
expect(order).not_to be_empty
|
||||||
|
|
||||||
click_link "highest rated"
|
click_link "highest rated"
|
||||||
click_link "random"
|
click_link "random"
|
||||||
|
|
||||||
visit budget_investments_path(budget, heading_id: heading.id)
|
visit budget_investments_path(budget, heading_id: heading.id)
|
||||||
new_order = all(".budget-investment h3").collect { |i| i.text }
|
new_order = all(".budget-investment h3").map { |i| i.text }
|
||||||
|
|
||||||
expect(order).to eq(new_order)
|
expect(order).to eq(new_order)
|
||||||
end
|
end
|
||||||
@@ -662,7 +662,7 @@ describe "Budget Investments" do
|
|||||||
|
|
||||||
visit budget_investments_path(budget, heading_id: heading.id)
|
visit budget_investments_path(budget, heading_id: heading.id)
|
||||||
|
|
||||||
order = all(".budget-investment h3").collect { |i| i.text }
|
order = all(".budget-investment h3").map { |i| i.text }
|
||||||
expect(order).not_to be_empty
|
expect(order).not_to be_empty
|
||||||
|
|
||||||
click_link "Next"
|
click_link "Next"
|
||||||
@@ -671,7 +671,7 @@ describe "Budget Investments" do
|
|||||||
click_link "Previous"
|
click_link "Previous"
|
||||||
expect(page).to have_content "You're on page 1"
|
expect(page).to have_content "You're on page 1"
|
||||||
|
|
||||||
new_order = all(".budget-investment h3").collect { |i| i.text }
|
new_order = all(".budget-investment h3").map { |i| i.text }
|
||||||
expect(order).to eq(new_order)
|
expect(order).to eq(new_order)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -680,13 +680,13 @@ describe "Budget Investments" do
|
|||||||
|
|
||||||
visit budget_investments_path(budget, heading_id: heading.id)
|
visit budget_investments_path(budget, heading_id: heading.id)
|
||||||
|
|
||||||
order = all(".budget-investment h3").collect { |i| i.text }
|
order = all(".budget-investment h3").map { |i| i.text }
|
||||||
expect(order).not_to be_empty
|
expect(order).not_to be_empty
|
||||||
|
|
||||||
click_link Budget::Investment.first.title
|
click_link Budget::Investment.first.title
|
||||||
click_link "Go back"
|
click_link "Go back"
|
||||||
|
|
||||||
new_order = all(".budget-investment h3").collect { |i| i.text }
|
new_order = all(".budget-investment h3").map { |i| i.text }
|
||||||
expect(order).to eq(new_order)
|
expect(order).to eq(new_order)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -812,11 +812,11 @@ describe "Budget Investments" do
|
|||||||
budget.update!(phase: "finished")
|
budget.update!(phase: "finished")
|
||||||
|
|
||||||
visit budget_investments_path(budget, heading_id: heading.id)
|
visit budget_investments_path(budget, heading_id: heading.id)
|
||||||
order = all(".budget-investment h3").collect { |i| i.text }
|
order = all(".budget-investment h3").map { |i| i.text }
|
||||||
expect(order).not_to be_empty
|
expect(order).not_to be_empty
|
||||||
|
|
||||||
visit budget_investments_path(budget, heading_id: heading.id)
|
visit budget_investments_path(budget, heading_id: heading.id)
|
||||||
new_order = all(".budget-investment h3").collect { |i| i.text }
|
new_order = all(".budget-investment h3").map { |i| i.text }
|
||||||
|
|
||||||
expect(order).to eq(new_order)
|
expect(order).to eq(new_order)
|
||||||
end
|
end
|
||||||
@@ -844,7 +844,7 @@ describe "Budget Investments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def investments_order
|
def investments_order
|
||||||
all(".budget-investment h3").collect { |i| i.text }
|
all(".budget-investment h3").map { |i| i.text }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1038,7 +1038,7 @@ describe "Budget Investments" do
|
|||||||
|
|
||||||
visit new_budget_investment_path(budget)
|
visit new_budget_investment_path(budget)
|
||||||
|
|
||||||
select_options = find("#budget_investment_heading_id").all("option").collect(&:text)
|
select_options = find("#budget_investment_heading_id").all("option").map(&:text)
|
||||||
expect(select_options).to eq ["",
|
expect(select_options).to eq ["",
|
||||||
"Toda la ciudad",
|
"Toda la ciudad",
|
||||||
"Health: More health professionals",
|
"Health: More health professionals",
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ describe "Legislation Proposals" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def legislation_proposals_order
|
def legislation_proposals_order
|
||||||
all("[id^='legislation_proposal_']").collect { |e| e[:id] }
|
all("[id^='legislation_proposal_']").map { |e| e[:id] }
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Create a legislation proposal with an image", :js do
|
scenario "Create a legislation proposal with an image", :js do
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ end
|
|||||||
|
|
||||||
def extract_fields(response, collection_name, field_chain)
|
def extract_fields(response, collection_name, field_chain)
|
||||||
fields = field_chain.split(".")
|
fields = field_chain.split(".")
|
||||||
dig(response, "data.#{collection_name}.edges").collect do |node|
|
dig(response, "data.#{collection_name}.edges").map do |node|
|
||||||
begin
|
begin
|
||||||
if fields.size > 1
|
if fields.size > 1
|
||||||
node["node"][fields.first][fields.second]
|
node["node"][fields.first][fields.second]
|
||||||
@@ -60,8 +60,8 @@ describe "Consul Schema" do
|
|||||||
comment_2 = create(:comment, author: comments_author, commentable: proposal)
|
comment_2 = create(:comment, author: comments_author, commentable: proposal)
|
||||||
|
|
||||||
response = execute("{ proposal(id: #{proposal.id}) { comments { edges { node { body } } } } }")
|
response = execute("{ proposal(id: #{proposal.id}) { comments { edges { node { body } } } } }")
|
||||||
comments = dig(response, "data.proposal.comments.edges").collect { |edge| edge["node"] }
|
comments = dig(response, "data.proposal.comments.edges").map { |edge| edge["node"] }
|
||||||
comment_bodies = comments.collect { |comment| comment["body"] }
|
comment_bodies = comments.map { |comment| comment["body"] }
|
||||||
|
|
||||||
expect(comment_bodies).to match_array([comment_1.body, comment_2.body])
|
expect(comment_bodies).to match_array([comment_1.body, comment_2.body])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ describe LocalCensusRecords::Import do
|
|||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
valid_document_numbers = ["44556678T", "33556678T", "22556678T", "X11556678"]
|
valid_document_numbers = ["44556678T", "33556678T", "22556678T", "X11556678"]
|
||||||
expect(import.created_records.collect(&:document_number)).to eq(valid_document_numbers)
|
expect(import.created_records.map(&:document_number)).to eq(valid_document_numbers)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "Add invalid local census records to invalid_records array" do
|
it "Add invalid local census records to invalid_records array" do
|
||||||
@@ -74,13 +74,13 @@ describe LocalCensusRecords::Import do
|
|||||||
invalid_records_date_of_births = [Date.parse("07/08/1984"), Date.parse("07/08/1985"), nil,
|
invalid_records_date_of_births = [Date.parse("07/08/1984"), Date.parse("07/08/1985"), nil,
|
||||||
Date.parse("07/08/1987")]
|
Date.parse("07/08/1987")]
|
||||||
invalid_records_postal_codes = ["7008", "7009", "7010", nil]
|
invalid_records_postal_codes = ["7008", "7009", "7010", nil]
|
||||||
expect(import.invalid_records.collect(&:document_type))
|
expect(import.invalid_records.map(&:document_type))
|
||||||
.to eq(invalid_records_document_types)
|
.to eq(invalid_records_document_types)
|
||||||
expect(import.invalid_records.collect(&:document_number))
|
expect(import.invalid_records.map(&:document_number))
|
||||||
.to eq(invalid_records_document_numbers)
|
.to eq(invalid_records_document_numbers)
|
||||||
expect(import.invalid_records.collect(&:date_of_birth))
|
expect(import.invalid_records.map(&:date_of_birth))
|
||||||
.to eq(invalid_records_date_of_births)
|
.to eq(invalid_records_date_of_births)
|
||||||
expect(import.invalid_records.collect(&:postal_code))
|
expect(import.invalid_records.map(&:postal_code))
|
||||||
.to eq(invalid_records_postal_codes)
|
.to eq(invalid_records_postal_codes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user