Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed Jun 20, 2024
1 parent 03fc375 commit 6d1c5b2
Show file tree
Hide file tree
Showing 63 changed files with 270 additions and 263 deletions.
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ group :development, :test do
end

group :development do
gem "decidim-admin", DECIDIM_VERSION
gem "decidim-assemblies", DECIDIM_VERSION
gem "decidim-debates", DECIDIM_VERSION
gem "decidim-meetings", DECIDIM_VERSION
gem "decidim-proposals", DECIDIM_VERSION
gem "letter_opener_web", "~> 2.0"
gem "listen", "~> 3.8"
gem "spring", "~> 4.1.3"
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -842,11 +842,16 @@ DEPENDENCIES
brakeman (~> 5.2)
byebug (~> 11.0)
decidim (~> 0.28.0)
decidim-admin (~> 0.28.0)
decidim-assemblies (~> 0.28.0)
decidim-conferences (~> 0.28.0)
decidim-debates (~> 0.28.0)
decidim-dev (~> 0.28.0)
decidim-elections (~> 0.28.0)
decidim-initiatives (~> 0.28.0)
decidim-meetings (~> 0.28.0)
decidim-privacy!
decidim-proposals (~> 0.28.0)
faker (~> 3.2.2)
letter_opener_web (~> 2.0)
listen (~> 3.8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ module ApplicationControllerExtensions
def privacy_modal_snippets
return unless respond_to?(:snippets)

if current_user && !current_user.public? && user_signed_in?
snippets.add(:foot, helpers.cell("decidim/privacy/publish_account_modal", current_user))
end
snippets.add(:foot, helpers.cell("decidim/privacy/publish_account_modal", current_user)) if current_user && !current_user.public? && user_signed_in?
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class PrivacySettingsController < ::Decidim::ApplicationController
include Decidim::UserProfile

def show
enforce_permission_to :read, :user, current_user: current_user
enforce_permission_to(:read, :user, current_user:)
@privacy_settings = form(::Decidim::Privacy::PrivacySettingsForm).from_model(current_user)
end

def update
enforce_permission_to :read, :user, current_user: current_user
enforce_permission_to(:read, :user, current_user:)
@privacy_settings = form(::Decidim::Privacy::PrivacySettingsForm).from_params(params)

UpdatePrivacySettings.call(current_user, @privacy_settings) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module ActionAuthorizationHelperExtensions
private

# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
def authorized_to(tag, action, arguments, block)
if block
body = block
Expand Down Expand Up @@ -56,6 +57,7 @@ def authorized_to(tag, action, arguments, block)
end
end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/CyclomaticComplexity
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def bulk_valuators_select(participatory_space, prompt)

# Internal: A method to cache to queries to find the valuators for the
# current space.
# rubocop:disable Rails/HelperInstanceVariable
def find_valuators_for_select(participatory_space)
return @valuators_for_select if @valuators_for_select

Expand All @@ -33,6 +34,7 @@ def find_valuators_for_select(participatory_space)
[valuator.name, role.id]
end
end
# rubocop:enable Rails/HelperInstanceVariable
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module StatsUsersCountExtensions
included do
def query
users = Decidim::User.entire_collection.where(organization: @organization).not_deleted.not_blocked.confirmed
users = users.where("created_at >= ?", @start_at) if @start_at.present?
users = users.where("created_at <= ?", @end_at) if @end_at.present?
users = users.where(created_at: @start_at..) if @start_at.present?
users = users.where(created_at: ..@end_at) if @end_at.present?
users.count
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
class AddAllowPrivateMessagingToDecidimUser < ActiveRecord::Migration[6.1]
def change
add_column :decidim_users, :allow_private_messaging, :boolean, default: true
change_column_null :decidim_users, :allow_private_messaging, false
end
end
5 changes: 0 additions & 5 deletions decidim-privacy.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,5 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,lib}/**/*", "LICENSE-AGPLv3.txt", "Rakefile", "README.md", "db/migrate"]

s.add_dependency "decidim-core", Decidim::Privacy.decidim_version
s.add_development_dependency "decidim-admin", Decidim::Privacy.decidim_version
s.add_development_dependency "decidim-assemblies", Decidim::Privacy.decidim_version
s.add_development_dependency "decidim-debates", Decidim::Privacy.decidim_version
s.add_development_dependency "decidim-meetings", Decidim::Privacy.decidim_version
s.add_development_dependency "decidim-proposals", Decidim::Privacy.decidim_version
s.metadata["rubygems_mfa_required"] = "true"
end
3 changes: 2 additions & 1 deletion lib/decidim/api/interfaces/author_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def organization_name

def self.resolve_type(obj, _ctx)
return Decidim::Core::UserType if obj.is_a?(Decidim::User) || obj.is_a?(Decidim::Privacy::PrivateUser)
return Decidim::Core::UserGroupType if obj.is_a? Decidim::UserGroup

Decidim::Core::UserGroupType if obj.is_a? Decidim::UserGroup
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/decidim/api/interfaces/coauthorable_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def public?(author)
end

def deleted?(author)
return if author.blank?
return false if author.blank?

!author.deleted_at.nil?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/decidim/privacy/test/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
factory :privacy_component, parent: :component do
name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :privacy).i18n_name }
manifest_name { :privacy }
participatory_space { create(:participatory_process, :with_steps) }
participatory_space { association(:participatory_process, :with_steps) }
end

FactoryBot.modify do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class ImpersonatableUsersController < Decidim::Admin::ApplicationController
end
end

describe Decidim::Admin::ImpersonatableUsersController, type: :controller do
describe Decidim::Admin::ImpersonatableUsersController do
routes { Decidim::Admin::Engine.routes }

let(:organization) { create :organization }
let(:admin_user) { create(:user, :admin, :confirmed, organization: organization) }
let(:private_user) { create(:user, organization: organization) }
let(:public_user) { create(:user, organization: organization, published_at: Time.current) }
let(:another_admin) { create(:user, :admin, :confirmed, organization: organization) }
let(:organization) { create(:organization) }
let(:admin_user) { create(:user, :admin, :confirmed, organization:) }
let(:private_user) { create(:user, organization:) }
let(:public_user) { create(:user, organization:, published_at: Time.current) }
let(:another_admin) { create(:user, :admin, :confirmed, organization:) }

describe "#index" do
before do
Expand Down
26 changes: 13 additions & 13 deletions spec/controllers/decidim/admin/organization_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ class OrganizationController < Decidim::Admin::ApplicationController
end
end

describe Decidim::Admin::OrganizationController, type: :controller do
describe Decidim::Admin::OrganizationController do
routes { Decidim::Admin::Engine.routes }

let(:organization) { create :organization }
let(:current_user) { create(:user, :admin, :confirmed, organization: organization) }
let(:organization) { create(:organization) }
let(:current_user) { create(:user, :admin, :confirmed, organization:) }

before do
request.env["decidim.current_organization"] = organization
sign_in current_user, scope: :user
end

describe "GET users and user groups in json format" do
let(:parsed_response) { JSON.parse(response.body).map(&:symbolize_keys) }
let(:parsed_response) { response.parsed_body.map(&:symbolize_keys) }

context "when user is blocked" do
let!(:user) { create(:user, :blocked, name: "Daisy Miller", nickname: "daisy_m", organization: organization) }
let!(:user) { create(:user, :blocked, name: "Daisy Miller", nickname: "daisy_m", organization:) }

it "returns an empty json array" do
get :users, format: :json, params: { term: "daisy" }
Expand All @@ -34,7 +34,7 @@ class OrganizationController < Decidim::Admin::ApplicationController
end

context "when user is managed" do
let!(:user) { create(:user, :managed, name: "Daisy Miller", nickname: "daisy_m", organization: organization) }
let!(:user) { create(:user, :managed, name: "Daisy Miller", nickname: "daisy_m", organization:) }

it "returns an empty json array" do
get :users, format: :json, params: { term: "daisy" }
Expand All @@ -43,7 +43,7 @@ class OrganizationController < Decidim::Admin::ApplicationController
end

context "when user is deleted" do
let!(:user) { create(:user, :deleted, name: "Daisy Miller", nickname: "daisy_m", organization: organization) }
let!(:user) { create(:user, :deleted, name: "Daisy Miller", nickname: "daisy_m", organization:) }

it "returns an empty json array" do
get :users, format: :json, params: { term: "daisy" }
Expand All @@ -53,11 +53,11 @@ class OrganizationController < Decidim::Admin::ApplicationController
end

describe "GET users in json format" do
let!(:user) { create(:user, name: "Daisy Miller", nickname: "daisy_m", organization: organization) }
let!(:public_user) { create(:user, name: "Daisy Public", nickname: "daisy_p", organization: organization, published_at: Time.current) }
let!(:user) { create(:user, name: "Daisy Miller", nickname: "daisy_m", organization:) }
let!(:public_user) { create(:user, name: "Daisy Public", nickname: "daisy_p", organization:, published_at: Time.current) }
let!(:other_organization_user) { create(:user, name: "Daisy Foo", nickname: "daisy_f", published_at: Time.current) }

let(:parsed_response) { JSON.parse(response.body).map(&:symbolize_keys) }
let(:parsed_response) { response.parsed_body.map(&:symbolize_keys) }

context "when searching by name" do
it "returns the id, name and nickname for filtered users" do
Expand All @@ -83,7 +83,7 @@ class OrganizationController < Decidim::Admin::ApplicationController
end

context "when user is blocked" do
let!(:user) { create(:user, :blocked, name: "Daisy Miller", nickname: "daisy_m", organization: organization) }
let!(:user) { create(:user, :blocked, name: "Daisy Miller", nickname: "daisy_m", organization:) }

it "returns an empty json array" do
get :users, format: :json, params: { term: "daisy" }
Expand All @@ -92,7 +92,7 @@ class OrganizationController < Decidim::Admin::ApplicationController
end

context "when user is managed" do
let!(:user) { create(:user, :managed, name: "Daisy Miller", nickname: "daisy_m", organization: organization) }
let!(:user) { create(:user, :managed, name: "Daisy Miller", nickname: "daisy_m", organization:) }

it "returns an empty json array" do
get :users, format: :json, params: { term: "daisy" }
Expand All @@ -101,7 +101,7 @@ class OrganizationController < Decidim::Admin::ApplicationController
end

context "when user is deleted" do
let!(:user) { create(:user, :deleted, name: "Daisy Miller", nickname: "daisy_m", organization: organization) }
let!(:user) { create(:user, :deleted, name: "Daisy Miller", nickname: "daisy_m", organization:) }

it "returns an empty json array" do
get :users, format: :json, params: { term: "daisy" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AssemblyMembersController
end
end

describe Decidim::Assemblies::AssemblyMembersController, type: :controller do
describe Decidim::Assemblies::AssemblyMembersController do
routes { Decidim::Assemblies::Engine.routes }

let(:organization) { create(:organization) }
Expand All @@ -19,7 +19,7 @@ class AssemblyMembersController
create(
:assembly,
:published,
organization: organization
organization:
)
end

Expand All @@ -32,20 +32,20 @@ class AssemblyMembersController
it "displays an empty array of members" do
get :index, params: { assembly_slug: assembly.slug }

expect(controller.helpers.collection).to match_array([])
expect(controller.helpers.collection).to be_empty
end
end

context "when there are members" do
let!(:member1) { create(:assembly_member, :with_user, assembly: assembly) }
let!(:member2) { create(:assembly_member, assembly: assembly) }
let!(:first_member) { create(:assembly_member, :with_user, assembly:) }
let!(:second_member) { create(:assembly_member, assembly:) }
let!(:non_member) { create(:assembly_member) }

context "when assembly has no public members" do
it "displays an empty array of members" do
get :index, params: { assembly_slug: assembly.slug }

expect(controller.helpers.collection).to match_array([])
expect(controller.helpers.collection).to be_empty
end
end

Expand All @@ -58,7 +58,7 @@ class AssemblyMembersController
it "displays only public members" do
get :index, params: { assembly_slug: assembly.slug }

expect(controller.helpers.collection).to match_array([member1])
expect(controller.helpers.collection).to contain_exactly(member1)
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/controllers/decidim/comments/comments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

require "spec_helper"

describe Decidim::Comments::CommentsController, type: :controller do
describe Decidim::Comments::CommentsController do
routes { Decidim::Comments::Engine.routes }

let(:organization) { create(:organization) }
let(:participatory_process) { create :participatory_process, organization: organization }
let(:participatory_process) { create(:participatory_process, organization:) }
let(:component) { create(:component, participatory_space: participatory_process) }
let(:commentable) { create(:dummy_resource, component: component) }
let(:commentable) { create(:dummy_resource, component:) }

before do
request.env["decidim.current_organization"] = organization
end

describe "POST create" do
let(:user) { create(:user, :confirmed, locale: "en", organization: organization) }
let(:user) { create(:user, :confirmed, locale: "en", organization:) }
let(:comment) { Decidim::Comments::Comment.last }
let(:params) do
{ comment: comment_params, xhr: true }
Expand All @@ -35,7 +35,7 @@
end

it "does not permit create action" do
post :create, xhr: true, params: params
post(:create, xhr: true, params:)
expect(response).to render_template("decidim/privacy/privacy_block")
end
end
Expand All @@ -47,7 +47,7 @@
end

it "permits create action" do
post :create, xhr: true, params: params
post(:create, xhr: true, params:)
expect(response).to have_http_status(:ok).or have_http_status(:no_content)
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/decidim/debates/debates_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

require "spec_helper"

describe Decidim::Debates::DebatesController, type: :controller do
describe Decidim::Debates::DebatesController do
routes { Decidim::Debates::Engine.routes }

let(:organization) { create(:organization) }
let(:component) { create(:debates_component, :with_creation_enabled, organization: organization) }
let!(:debate) { create(:debate, component: component, author: user) }
let(:user) { create(:user, :confirmed, organization: organization) }
let(:component) { create(:debates_component, :with_creation_enabled, organization:) }
let!(:debate) { create(:debate, component:, author: user) }
let(:user) { create(:user, :confirmed, organization:) }
let(:params) { { component_id: component.id } }

before do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}

allow(organization).to receive(:available_authorizations)
.and_return(["facebook"])
.and_return(["dummy_authorization"])
end

context "with successful sign in" do
Expand Down
Loading

0 comments on commit 6d1c5b2

Please sign in to comment.