Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
antopalidi committed Sep 26, 2023
1 parent da96642 commit 1c2f417
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ GEM
wkhtmltopdf-binary (0.12.6.6)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.11)
zeitwerk (2.6.12)

PLATFORMS
x86_64-darwin-22
Expand Down
2 changes: 1 addition & 1 deletion app/middleware/assemblies_scoper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def out_of_scope?
end

def types
AssembliesScoper.alternative_assembly_types.map { |item| [item[:key], item[:assembly_type_ids]] }.to_h
AssembliesScoper.alternative_assembly_types.to_h { |item| [item[:key], item[:assembly_type_ids]] }
end

def type_for(type_id)
Expand Down
2 changes: 1 addition & 1 deletion app/middleware/participatory_processes_scoper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def find_participatory_process
end

def out_of_scope?
scoped_slug_prefixes.blank? || request_slug && @current_participatory_process.blank?
scoped_slug_prefixes.blank? || (request_slug && @current_participatory_process.blank?)
end

def find_alternative_namespace
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/anonimize.rake
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace :anonymize do
unconfirmed_email: nil,
avatar: nil,
extra: {},
extended_data: user_group.extended_data.merge("phone": "123456789", "document_number": "document-#{user_group.id}")
extended_data: user_group.extended_data.merge(phone: "123456789", document_number: "document-#{user_group.id}")
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/admin/create_response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module Decidim::Consultations::Admin

context "when everything is ok" do
it "creates a response" do
expect { subject.call }.to change { Decidim::Consultations::Response.count }.by(1)
expect { subject.call }.to change(Decidim::Consultations::Response, :count).by(1)
expect(Decidim::Consultations::Response.last.weight).to eq(3)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/commands/admin/update_question_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module Decidim::Consultations::Admin
question.reload

expect(question.min_votes).to eq(3)
expect(question.enforce_special_requirements).to eq(true)
expect(question.enforce_special_requirements).to be(true)
end
end

Expand All @@ -48,7 +48,7 @@ module Decidim::Consultations::Admin
question.reload

expect(question.min_votes).to eq(3)
expect(question.enforce_special_requirements).to eq(false)
expect(question.enforce_special_requirements).to be(false)
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/consultations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ module Decidim::Consultations

context "when there are multiple consultations" do
let(:scope) { create(:scope, organization: organization) }
let!(:consultation_1) { create(:consultation, organization: organization, published_at: 2.days.ago) }
let!(:consultation_2) { create(:consultation, organization: organization, highlighted_scope: scope, published_at: 1.day.ago) }
let!(:consultation_one) { create(:consultation, organization: organization, published_at: 2.days.ago) }
let!(:consultation_two) { create(:consultation, organization: organization, highlighted_scope: scope, published_at: 1.day.ago) }

it "can access the index, ordered by recent" do
get :index

expect(subject).to render_template(:index)

expect(controller.helpers.consultations).to eq([consultation_2, consultation_1])
expect(controller.helpers.consultations).to eq([consultation_two, consultation_one])
expect(controller.send(:default_order)).to eq("recent")
expect(controller.send(:available_orders)).to eq(%w(recent random))
end
Expand All @@ -51,7 +51,7 @@ module Decidim::Consultations

expect(subject).to render_template(:index)

expect(controller.helpers.consultations).to match_array([consultation_2])
expect(controller.helpers.consultations).to match_array([consultation_two])
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Decidim::Admin
end

context "when email is missing" do
let(:email) {}
let(:email) { nil }

it { is_expected.to be_invalid }
end
Expand Down
4 changes: 2 additions & 2 deletions spec/forms/admin/question_configuration_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Decidim::Consultations::Admin
expect(subject.max_votes).to eq(2)
expect(subject.min_votes).to eq(1)
expect(subject.instructions).to eq("Instructions")
expect(subject.enforce_special_requirements).to eq(false)
expect(subject.enforce_special_requirements).to be(false)
end

context "when enfore_special_requirements is true" do
Expand All @@ -34,7 +34,7 @@ module Decidim::Consultations::Admin
expect(subject.max_votes).to eq(2)
expect(subject.min_votes).to eq(1)
expect(subject.instructions).to eq("Instructions")
expect(subject.enforce_special_requirements).to eq(true)
expect(subject.enforce_special_requirements).to be(true)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Admin
it "creates a new participatory private user" do
expect { described_class.perform_now(email, user_name, privatable_to, user) }.to change(Decidim::ParticipatorySpacePrivateUser, :count).by(1)
expect(Decidim::ParticipatorySpacePrivateUser.count).to eq 1
expect(Decidim::ParticipatorySpacePrivateUser.last.cas_user).to eq true
expect(Decidim::ParticipatorySpacePrivateUser.last.cas_user).to be true
end
end
end
Expand Down
24 changes: 12 additions & 12 deletions spec/services/meeting_sort_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
module SomEnergia::Meetings
describe MeetingSort do
let(:component) { create(:component, manifest_name: "meetings") }
let(:upcoming_meeting_1) { create(:meeting, :upcoming, component: component, start_time: 1.year.from_now) }
let(:upcoming_meeting_2) { create(:meeting, :upcoming, component: component, start_time: 2.years.from_now) }
let(:past_meeting_1) { create(:meeting, :past, component: component, start_time: 1.year.ago) }
let(:past_meeting_2) { create(:meeting, :past, component: component, start_time: 2.years.ago) }
let(:upcoming_meeting_one) { create(:meeting, :upcoming, component: component, start_time: 1.year.from_now) }
let(:upcoming_meeting_two) { create(:meeting, :upcoming, component: component, start_time: 2.years.from_now) }
let(:past_meeting_one) { create(:meeting, :past, component: component, start_time: 1.year.ago) }
let(:past_meeting_two) { create(:meeting, :past, component: component, start_time: 2.years.ago) }
let(:meetings) do
[
past_meeting_2,
upcoming_meeting_2,
past_meeting_1,
upcoming_meeting_1
past_meeting_two,
upcoming_meeting_two,
past_meeting_one,
upcoming_meeting_one
]
end

Expand All @@ -25,10 +25,10 @@ module SomEnergia::Meetings
let(:expected_ids) { expected_meetings.map(&:id) }
let(:expected_meetings) do
[
upcoming_meeting_1,
upcoming_meeting_2,
past_meeting_1,
past_meeting_2
upcoming_meeting_one,
upcoming_meeting_two,
past_meeting_one,
past_meeting_two
]
end

Expand Down
24 changes: 12 additions & 12 deletions spec/system/assemblies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
create(
:assembly,
slug: "slug1",
scope: scope_1,
area: area_1,
scope: first_scope,
area: first_area,
assembly_type: local_groups,
organization: organization
)
Expand All @@ -20,8 +20,8 @@
create(
:assembly,
slug: "slug2",
scope: scope_2,
area: area_2,
scope: second_scope,
area: second_area,
assembly_type: nil,
organization: organization
)
Expand All @@ -30,16 +30,16 @@
create(
:assembly,
slug: "slug3",
scope: scope_2,
area: area_2,
scope: second_scope,
area: second_area,
assembly_type: type2,
organization: organization
)
end
let!(:scope_1) { create(:scope, organization: organization) }
let!(:scope_2) { create(:scope, organization: organization) }
let!(:area_1) { create(:area, organization: organization) }
let!(:area_2) { create(:area, organization: organization) }
let!(:first_scope) { create(:scope, organization: organization) }
let!(:second_scope) { create(:scope, organization: organization) }
let!(:first_area) { create(:area, organization: organization) }
let!(:second_area) { create(:area, organization: organization) }

before do
switch_to_host(organization.host)
Expand Down Expand Up @@ -110,7 +110,7 @@
click_link "Select a scope"
end
within "#data_picker-modal" do
click_link translated(scope_1.name)
click_link translated(first_scope.name)
click_link "Select"
end
end
Expand All @@ -132,7 +132,7 @@
before do
within "#participatory-space-filters" do
select "Select an area"
select translated(area_1.name)
select translated(first_area.name)
end
end

Expand Down
32 changes: 16 additions & 16 deletions spec/system/consultations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@

describe "Consultations", type: :system do
let!(:organization) { create(:organization) }
let!(:consultation_1) do
let!(:consultation_one) do
create(
:consultation,
:published,
highlighted_scope: grand_child_scope_1,
highlighted_scope: grand_child_scope_one,
organization: organization
)
end
let!(:consultation_2) do
let!(:consultation_two) do
create(
:consultation,
:published,
highlighted_scope: child_scope_2,
highlighted_scope: child_scope_two,
organization: organization
)
end
let!(:parent_scope_1) { create(:scope, organization: organization) }
let!(:parent_scope_2) { create(:scope, organization: organization) }
let!(:child_scope_1) { create(:scope, parent: parent_scope_1) }
let!(:child_scope_2) { create(:scope, parent: parent_scope_1) }
let!(:grand_child_scope_1) { create(:scope, parent: child_scope_1) }
let!(:parent_scope_one) { create(:scope, organization: organization) }
let!(:parent_scope_two) { create(:scope, organization: organization) }
let!(:child_scope_one) { create(:scope, parent: parent_scope_one) }
let!(:child_scope_two) { create(:scope, parent: parent_scope_one) }
let!(:grand_child_scope_one) { create(:scope, parent: child_scope_one) }

before do
switch_to_host(organization.host)
Expand All @@ -37,30 +37,30 @@
before do
within(".highlighted_scope_ids_check_boxes_tree_filter") do
uncheck("All")
check(translated(parent_scope_1.name))
check(translated(parent_scope_one.name))
end
end

it "shows expected consultations" do
within("#consultations") do
expect(page).to have_i18n_content(consultation_1.title)
expect(page).to have_i18n_content(consultation_2.title)
expect(page).to have_i18n_content(consultation_one.title)
expect(page).to have_i18n_content(consultation_two.title)
end
end
end

context "when filtering by child scope" do
before do
within(".highlighted_scope_ids_check_boxes_tree_filter") do
find("label", text: translated(parent_scope_1.name)).sibling("button").click
check(translated(child_scope_2.name))
find("label", text: translated(parent_scope_one.name)).sibling("button").click
check(translated(child_scope_two.name))
end
end

it "shows expected consultations" do
within("#consultations") do
expect(page).to have_i18n_content(consultation_2.title)
expect(page).not_to have_i18n_content(consultation_1.title)
expect(page).to have_i18n_content(consultation_two.title)
expect(page).not_to have_i18n_content(consultation_one.title)
end
end
end
Expand Down
28 changes: 14 additions & 14 deletions spec/system/participatory_processes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
:participatory_process,
:active,
slug: "#{scoped_slug_prefix}-slug",
scope: scope_1,
area: area_1,
scope: first_scope,
area: first_area,
organization: organization
)
end
Expand All @@ -20,8 +20,8 @@
:participatory_process,
:past,
slug: "#{scoped_slug_prefix}-slug2",
scope: scope_2,
area: area_2,
scope: second_scope,
area: second_area,
organization: organization
)
end
Expand All @@ -30,8 +30,8 @@
:participatory_process,
:active,
slug: "normal-slug",
scope: scope_1,
area: area_1,
scope: first_scope,
area: first_area,
organization: organization
)
end
Expand All @@ -40,15 +40,15 @@
:participatory_process,
:past,
slug: "normal-slug2",
scope: scope_2,
area: area_2,
scope: second_scope,
area: second_area,
organization: organization
)
end
let!(:scope_1) { create(:scope, organization: organization) }
let!(:scope_2) { create(:scope, organization: organization) }
let!(:area_1) { create(:area, organization: organization) }
let!(:area_2) { create(:area, organization: organization) }
let!(:first_scope) { create(:scope, organization: organization) }
let!(:second_scope) { create(:scope, organization: organization) }
let!(:first_area) { create(:area, organization: organization) }
let!(:second_area) { create(:area, organization: organization) }

before do
switch_to_host(organization.host)
Expand Down Expand Up @@ -151,7 +151,7 @@
click_link "Select a scope"
end
within "#data_picker-modal" do
click_link translated(scope_1.name)
click_link translated(first_scope.name)
click_link "Select"
end
end
Expand All @@ -172,7 +172,7 @@
before do
within "#participatory-space-filters" do
select "Select an area"
select translated(area_1.name)
select translated(first_area.name)
end
end

Expand Down

0 comments on commit 1c2f417

Please sign in to comment.