Skip to content

Commit

Permalink
Fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed May 17, 2024
1 parent 0b93cca commit ab4b4bd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 34 deletions.
5 changes: 0 additions & 5 deletions decidim-suomifi.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,4 @@ Gem::Specification.new do |spec|
spec.add_dependency "decidim-core", Decidim::Suomifi::DECIDIM_VERSION
spec.add_dependency "henkilotunnus", "~> 1.2.0"
spec.add_dependency "omniauth-suomifi", "~> 0.7.0"

spec.add_development_dependency "decidim-dev", Decidim::Suomifi::DECIDIM_VERSION

# Required for encoding the SAML responses
spec.add_development_dependency "xmlenc", "~> 0.7.1"
end
2 changes: 1 addition & 1 deletion lib/tasks/suomifi_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace :decidim do
namespace :suomifi do
desc "Copy pin digest from metadata to its own column"
task copy_pin_digests: :environment do
::Decidim::Authorization.all.each do |authorization|
Decidim::Authorization.all.each do |authorization|
next if authorization.name != "suomifi_eid" || authorization.pseudonymized_pin.present?

authorization.update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Suomifi

# For testing with signed in user
let(:confirmed_user) do
create(:user, :confirmed, organization: organization)
create(:user, :confirmed, organization:)
end

before do
Expand Down
11 changes: 5 additions & 6 deletions spec/lib/decidim/suomifi/generators/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@

let(:secrets_yml) do
secrets_yml_template.gsub(
/%SUOMIFI_INJECTION_DEFAULT%/,
"%SUOMIFI_INJECTION_DEFAULT%",
""
).gsub(
/%SUOMIFI_INJECTION_DEVELOPMENT%/,
"%SUOMIFI_INJECTION_DEVELOPMENT%",
""
)
end
Expand All @@ -120,17 +120,16 @@
development += " icon: globe-line\n"

secrets_yml_template.gsub(
/%SUOMIFI_INJECTION_DEFAULT%/,
"%SUOMIFI_INJECTION_DEFAULT%",
default
).gsub(
/%SUOMIFI_INJECTION_DEVELOPMENT%/,
"%SUOMIFI_INJECTION_DEVELOPMENT%",
development
)
end

it "enables the Suomi.fi authentication by modifying the secrets.yml file" do
allow(File).to receive(:read).and_return(secrets_yml)
allow(File).to receive(:readlines).and_return(secrets_yml.lines)
allow(File).to receive_messages(read: secrets_yml, readlines: secrets_yml.lines)
expect(File).to receive(:open).with(anything, "w") do |&block|
file = double
expect(file).to receive(:puts).with(secrets_yml_modified)
Expand Down
31 changes: 10 additions & 21 deletions spec/lib/decidim/suomifi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
let(:certificate) { double }

it "returns what is set by the module configuration" do
allow(config).to receive(:certificate_file).and_return(nil)
allow(config).to receive(:certificate).and_return(certificate)
allow(config).to receive_messages(certificate_file: nil, certificate:)

expect(subject.certificate).to eq(certificate)
end
Expand All @@ -102,8 +101,7 @@
let(:private_key) { double }

it "returns what is set by the module configuration" do
allow(config).to receive(:private_key_file).and_return(nil)
allow(config).to receive(:private_key).and_return(private_key)
allow(config).to receive_messages(private_key_file: nil, private_key:)

expect(subject.private_key).to eq(private_key)
end
Expand All @@ -120,23 +118,15 @@
let(:extra) { { extra1: "abc", extra2: 123 } }

it "returns the expected omniauth configuration hash" do
allow(config).to receive(:mode).and_return(mode)
allow(config).to receive(:scope_of_data).and_return(scope_of_data)
allow(config).to receive(:sp_entity_id).and_return(sp_entity_id)
allow(config).to receive(:certificate_file).and_return(nil)
allow(config).to receive(:certificate).and_return(certificate)
allow(config).to receive(:private_key_file).and_return(nil)
allow(config).to receive(:private_key).and_return(private_key)
allow(config).to receive(:idp_slo_session_destroy).and_return(idp_slo_session_destroy)
allow(config).to receive(:extra).and_return(extra)
allow(config).to receive_messages(mode:, scope_of_data:, sp_entity_id:, certificate_file: nil, certificate:, private_key_file: nil, private_key:, idp_slo_session_destroy:, extra:)

expect(subject.omniauth_settings).to include(
mode: mode,
scope_of_data: scope_of_data,
sp_entity_id: sp_entity_id,
certificate: certificate,
private_key: private_key,
idp_slo_session_destroy: idp_slo_session_destroy,
mode:,
scope_of_data:,
sp_entity_id:,
certificate:,
private_key:,
idp_slo_session_destroy:,
extra1: "abc",
extra2: 123
)
Expand All @@ -153,8 +143,7 @@

before do
allow(Rails.application).to receive(:config).and_return(rails_config)
allow(rails_config).to receive(:action_controller).and_return(controller_config)
allow(rails_config).to receive(:action_mailer).and_return(mailer_config)
allow(rails_config).to receive_messages(action_controller: controller_config, action_mailer: mailer_config)
allow(controller_config).to receive(:default_url_options).and_return(controller_defaults)
allow(mailer_config).to receive(:default_url_options).and_return(mailer_defaults)
end
Expand Down

0 comments on commit ab4b4bd

Please sign in to comment.