From 976a015eebef9209a0e5fd4bc53bbb20cf448a20 Mon Sep 17 00:00:00 2001 From: Joonas Date: Wed, 15 May 2024 14:30:43 +0300 Subject: [PATCH] Update Ruboocop.yml --- .rubocop.yml | 89 ------------------- .../admin/permission_overrides.rb | 2 +- decidim-simple_proposal.gemspec | 2 - .../admin_manages_component_settings_spec.rb | 6 +- .../admin/admin_merges_proposals_spec.rb | 30 +++---- .../admin/admin_splits_proposals_spec.rb | 2 +- 6 files changed, 20 insertions(+), 111 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 13bc55c..e3c0100 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,94 +1,5 @@ inherit_gem: decidim-dev: rubocop-decidim.yml -inherit_mode: - merge: - - Exclude - -AllCops: - Exclude: - - "decidim-initiatives/lib/gem_overrides/origami/date.rb" - -Naming/FileName: - Exclude: - - "decidim-dev/lib/decidim-dev.rb" - -Metrics/CyclomaticComplexity: - Exclude: - - "decidim-admin/app/queries/decidim/admin/newsletter_recipients.rb" - -Metrics/ParameterLists: - Exclude: - - "decidim-core/lib/decidim/filter_form_builder.rb" - -Metrics/PerceivedComplexity: - Exclude: - - "decidim-admin/app/queries/decidim/admin/newsletter_recipients.rb" - RSpec/DescribeClass: - Exclude: - - decidim-core/spec/lib/global_engines_spec.rb - -RSpec/EmptyExampleGroup: - Exclude: - - decidim-core/spec/lib/participatory_space_manifest_spec.rb - -RSpec/MultipleMemoizedHelpers: - Exclude: - - decidim-assemblies/spec/forms/assembly_form_spec.rb - -Rails/Output: - Exclude: - - lib/decidim/git_backport_manager.rb - - lib/decidim/github_manager/poster.rb - - decidim-core/lib/decidim/core.rb - - decidim-core/lib/decidim/component_manifest.rb - - decidim-core/lib/decidim/participatory_space_manifest.rb - -Rails/Exit: - Exclude: - - lib/decidim/git_backport_manager.rb - -RSpec/NoExpectationExample: - Exclude: - - decidim-admin/spec/system/participatory_space_private_user_spec.rb - - decidim-comments/spec/services/decidim/comments/comment_creation_spec.rb - - decidim-conferences/spec/cells/decidim/conferences/conference_speaker_cell_spec.rb - - decidim-core/spec/cells/decidim/date_range_cell_spec.rb - - decidim-core/spec/commands/decidim/unsubscribe_settings_spec.rb - - decidim-core/spec/controllers/registrations_controller_spec.rb - - decidim-core/spec/lib/importers/import_manifest_spec.rb - - decidim-core/spec/lib/map/geocoding_spec.rb - - decidim-core/spec/lib/participatory_space_manifest_spec.rb - - decidim-core/spec/services/decidim/events_manager_spec.rb - - decidim-core/spec/services/decidim/settings_change_spec.rb - - decidim-core/spec/services/decidim/zip_stream/zip_stream_writer_spec.rb - - decidim-core/spec/tasks/decidim_tasks_right_to_be_forgotten_spec.rb - - decidim-elections/spec/lib/tasks/decidim_election_generate_identification_keys_spec.rb - - decidim-elections/spec/lib/tasks/decidim_election_scheduled_tasks_spec.rb - - decidim-elections/spec/shared/vote_examples.rb - - decidim-elections/spec/system/key_ceremony_spec.rb - - decidim-elections/spec/system/vote_online_inside_a_voting_spec.rb - - decidim-initiatives/spec/system/admin/update_initiative_spec.rb - - decidim-initiatives/spec/system/initiative_signing_spec.rb - - decidim-meetings/spec/commands/admin/export_meeting_registrations_spec.rb - - decidim-meetings/spec/system/explore_meeting_directory_spec.rb - - decidim-meetings/spec/system/explore_meetings_spec.rb - - decidim-proposals/spec/lib/decidim/proposals/markdown_to_proposals_spec.rb - - decidim-proposals/spec/shared/import_proposals_examples.rb - - decidim-proposals/spec/shared/proposals_wizards_examples.rb - - decidim-proposals/spec/system/admin/admin_manages_participatory_texts_spec.rb - - decidim-proposals/spec/system/participatory_texts_spec.rb - - decidim-participatory_processes/spec/system/participatory_processes_spec.rb - -# fix these rules later -Capybara/SpecificFinders: - Enabled: false - -RSpec/IndexedLet: - Enabled: false - -Rails/HelperInstanceVariable: Enabled: false - -# EOF fix these rules later diff --git a/app/permissions/concerns/decidim/simple_proposal/admin/permission_overrides.rb b/app/permissions/concerns/decidim/simple_proposal/admin/permission_overrides.rb index 0008a13..2e491d0 100644 --- a/app/permissions/concerns/decidim/simple_proposal/admin/permission_overrides.rb +++ b/app/permissions/concerns/decidim/simple_proposal/admin/permission_overrides.rb @@ -8,7 +8,7 @@ module PermissionOverrides extend ActiveSupport::Concern included do def admin_edition_is_available? - return unless proposal + return false unless proposal proposal.official? || proposal.official_meeting? || proposal.authors.any? { |p| p.is_a?(Decidim::Organization) } end diff --git a/decidim-simple_proposal.gemspec b/decidim-simple_proposal.gemspec index 722d4cb..60bb16f 100644 --- a/decidim-simple_proposal.gemspec +++ b/decidim-simple_proposal.gemspec @@ -30,6 +30,4 @@ Gem::Specification.new do |spec| spec.add_dependency "decidim-core", Decidim::SimpleProposal::DECIDIM_VERSION spec.add_dependency "decidim-proposals", Decidim::SimpleProposal::DECIDIM_VERSION - - spec.add_development_dependency "decidim-dev", Decidim::SimpleProposal::DECIDIM_VERSION end diff --git a/spec/system/admin/admin_manages_component_settings_spec.rb b/spec/system/admin/admin_manages_component_settings_spec.rb index 9c9c181..4a8920f 100644 --- a/spec/system/admin/admin_manages_component_settings_spec.rb +++ b/spec/system/admin/admin_manages_component_settings_spec.rb @@ -26,17 +26,17 @@ end context "when there's antoher scope" do - let!(:scope2) { create(:scope, organization:) } + let!(:second_scope) { create(:scope, organization:) } before do visit current_path end it "can change scope" do - select scope2.name["en"], from: "component[settings][scope_id]" + select second_scope.name["en"], from: "component[settings][scope_id]" click_link_or_button "Update" expect(page).to have_content("The component was updated successfully") - expect(Decidim::Component.find(component.id).scope.id).to eq(scope2.id) + expect(Decidim::Component.find(component.id).scope.id).to eq(second_scope.id) end end end diff --git a/spec/system/admin/admin_merges_proposals_spec.rb b/spec/system/admin/admin_merges_proposals_spec.rb index 4bc5308..1b5ab08 100644 --- a/spec/system/admin/admin_merges_proposals_spec.rb +++ b/spec/system/admin/admin_merges_proposals_spec.rb @@ -52,56 +52,56 @@ end context "with multiple authors" do - let(:author3) { create(:user, :confirmed, organization:) } + let(:third_author) { create(:user, :confirmed, organization:) } let(:authors) { [author, another_author] } - let(:other_authors) { [author3, organization] } + let(:other_authors) { [third_author, organization] } it "merges two proposals into one with all the authors" do visit current_path merge_proposals([proposal, another_proposal]) expect(page).to have_css(".flash.success") expect(Decidim::Proposals::Proposal.where(deleted_at: nil).count).to eq(1) - expect(Decidim::Proposals::Proposal.last.authors).to include(author, another_author, author3, organization) + expect(Decidim::Proposals::Proposal.last.authors).to include(author, another_author, third_author, organization) expect(page).to have_css(".action-icon.action-icon--edit-proposal", count: 1) end end context "when proposals has comments" do let!(:comment) { create(:comment, commentable: proposal) } - let!(:comment2) { create(:comment, commentable: proposal) } - let!(:comment3) { create(:comment, commentable: another_proposal) } + let!(:second_comment) { create(:comment, commentable: proposal) } + let!(:third_comment) { create(:comment, commentable: another_proposal) } it "moves comments to merge proposal" do visit current_path merge_proposals([proposal, another_proposal]) merge_proposal = Decidim::Proposals::Proposal.last expect(merge_proposal.comments.count).to eq(3) - expect(merge_proposal.comments).to include(comment, comment2, comment3) + expect(merge_proposal.comments).to include(comment, second_comment, third_comment) end end context "when proposals have machine translations" do - let(:proposal) { create(:proposal, body: body1, component:, users: authors) } - let(:another_proposal) { create(:proposal, body: body2, component:, users: other_authors) } - let(:body1) do + let(:proposal) { create(:proposal, body: first_body, component:, users: authors) } + let(:another_proposal) { create(:proposal, body: second_body, component:, users: other_authors) } + let(:first_body) do { "en" => "Hello world", - "machine_translations" => machine_translations1 + "machine_translations" => first_machine_translations } end - let(:body2) do + let(:second_body) do { "en" => "This is a test sentence", - "machine_translations" => machine_translations2 + "machine_translations" => second_machine_translations } end - let(:machine_translations1) do + let(:first_machine_translations) do { "fi" => "Hei maailma", "sv" => "Hej världen" } end - let(:machine_translations2) do + let(:second_machine_translations) do { "fi" => "Tämä on testilause", "sv" => "Det här är en testmening" @@ -130,7 +130,7 @@ def merge_proposals(proposals) Array(proposals).each do |proposal| find(".js-proposal-id-#{proposal.id}").set(true) end - find("#js-bulk-actions-button").click + find_by_id("js-bulk-actions-button").click click_link_or_button "Merge into a new one" select translated(component.name), from: "target_component_id_" click_link_or_button "Merge" diff --git a/spec/system/admin/admin_splits_proposals_spec.rb b/spec/system/admin/admin_splits_proposals_spec.rb index 82ab0b1..d409ef0 100644 --- a/spec/system/admin/admin_splits_proposals_spec.rb +++ b/spec/system/admin/admin_splits_proposals_spec.rb @@ -81,7 +81,7 @@ def split_proposals(proposal_ids) Array(proposal_ids).each do |id| find(".js-proposal-id-#{id}").set(true) end - find("#js-bulk-actions-button").click + find_by_id("js-bulk-actions-button").click click_link_or_button "Split proposals" select translated(component.name), from: "target_component_id_" click_link_or_button "Split"