diff --git a/Gemfile b/Gemfile index a5697ec..80609b1 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem "decidim", Decidim::DirectVerifications::DECIDIM_VERSION gem "decidim-direct_verifications", path: "." gem "bootsnap", "~> 1.3" -gem "puma", "~> 3.0" +gem "puma", "~> 4.0" gem "uglifier", "~> 4.1" group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 173ce69..d98ae76 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,9 @@ PATH remote: . specs: - decidim-direct_verifications (0.20) - decidim-admin (>= 0.17.0) - decidim-core (>= 0.17.0) + decidim-direct_verifications (0.22) + decidim-admin (>= 0.22.0) + decidim-core (>= 0.22.0) GEM remote: https://rubygems.org/ @@ -82,6 +82,7 @@ GEM bindex (0.8.1) bootsnap (1.5.0) msgpack (~> 1.0) + browser (2.7.1) builder (3.2.4) byebug (11.1.3) capybara (3.33.0) @@ -108,6 +109,7 @@ GEM actionpack (>= 3.0) cells (>= 4.1.6, < 5.0.0) charlock_holmes (0.7.7) + chef-utils (16.6.14) childprocess (3.0.0) codecov (0.2.12) json @@ -132,91 +134,95 @@ GEM db-query-matchers (0.9.0) activesupport (>= 4.0, <= 6.0) rspec (~> 3.0) - decidim (0.20.0) - decidim-accountability (= 0.20.0) - decidim-admin (= 0.20.0) - decidim-api (= 0.20.0) - decidim-assemblies (= 0.20.0) - decidim-blogs (= 0.20.0) - decidim-budgets (= 0.20.0) - decidim-comments (= 0.20.0) - decidim-core (= 0.20.0) - decidim-debates (= 0.20.0) - decidim-forms (= 0.20.0) - decidim-generators (= 0.20.0) - decidim-meetings (= 0.20.0) - decidim-pages (= 0.20.0) - decidim-participatory_processes (= 0.20.0) - decidim-proposals (= 0.20.0) - decidim-sortitions (= 0.20.0) - decidim-surveys (= 0.20.0) - decidim-system (= 0.20.0) - decidim-verifications (= 0.20.0) - decidim-accountability (0.20.0) - decidim-comments (= 0.20.0) - decidim-core (= 0.20.0) - kaminari (~> 1.1) + decidim (0.22.0) + decidim-accountability (= 0.22.0) + decidim-admin (= 0.22.0) + decidim-api (= 0.22.0) + decidim-assemblies (= 0.22.0) + decidim-blogs (= 0.22.0) + decidim-budgets (= 0.22.0) + decidim-comments (= 0.22.0) + decidim-core (= 0.22.0) + decidim-debates (= 0.22.0) + decidim-forms (= 0.22.0) + decidim-generators (= 0.22.0) + decidim-meetings (= 0.22.0) + decidim-pages (= 0.22.0) + decidim-participatory_processes (= 0.22.0) + decidim-proposals (= 0.22.0) + decidim-sortitions (= 0.22.0) + decidim-surveys (= 0.22.0) + decidim-system (= 0.22.0) + decidim-verifications (= 0.22.0) + decidim-accountability (0.22.0) + decidim-comments (= 0.22.0) + decidim-core (= 0.22.0) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-admin (0.20.0) + decidim-admin (0.22.0) active_link_to (~> 1.0) - decidim-core (= 0.20.0) + decidim-core (= 0.22.0) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 1.7) jquery-rails (~> 4.3) - sassc (~> 1.12, >= 1.12.1) - sassc-rails (~> 1.3) - decidim-api (0.20.0) + sassc (~> 2.3.0) + sassc-rails (~> 2.1.2) + decidim-api (0.22.0) graphiql-rails (~> 1.4, < 1.5) graphql (~> 1.9) rack-cors (~> 1.0) + redcarpet (~> 3.4) sprockets-es6 (~> 0.9.2) - decidim-assemblies (0.20.0) - decidim-core (= 0.20.0) - decidim-blogs (0.20.0) - decidim-admin (= 0.20.0) - decidim-comments (= 0.20.0) - decidim-core (= 0.20.0) + decidim-assemblies (0.22.0) + decidim-core (= 0.22.0) + decidim-blogs (0.22.0) + decidim-admin (= 0.22.0) + decidim-comments (= 0.22.0) + decidim-core (= 0.22.0) httparty (~> 0.17) jquery-tmpl-rails (~> 1.1) - kaminari (~> 1.1) - decidim-budgets (0.20.0) - decidim-comments (= 0.20.0) - decidim-core (= 0.20.0) - kaminari (~> 1.1) + kaminari (~> 1.2, >= 1.2.1) + decidim-budgets (0.22.0) + decidim-comments (= 0.22.0) + decidim-core (= 0.22.0) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-comments (0.20.0) - decidim-core (= 0.20.0) + decidim-comments (0.22.0) + decidim-core (= 0.22.0) jquery-rails (~> 4.3) - decidim-core (0.20.0) + redcarpet (~> 3.4) + decidim-core (0.22.0) active_link_to (~> 1.0) anchored (>= 1.1.0) autoprefixer-rails (~> 8.0) batch-loader (~> 1.2) + browser (~> 2.7) carrierwave (~> 1.3) cells-erb (~> 0.1.0) cells-rails (~> 0.0.9) charlock_holmes (~> 0.7) date_validator (~> 0.9.0) - decidim-api (= 0.20.0) + decidim-api (= 0.22.0) devise (~> 4.7) devise-i18n (~> 1.2) + diffy (~> 3.3) doorkeeper (~> 5.1) doorkeeper-i18n (~> 4.0) etherpad-lite (~> 0.3) file_validators (~> 2.1) - foundation-rails (~> 6.4, < 6.5) + foundation-rails (~> 6.6, < 6.7) foundation_rails_helper (~> 3.0) - geocoder (~> 1.5) + geocoder (>= 1.5) hashdiff (>= 0.4.0, < 2.0.0) invisible_captcha (~> 0.12) jquery-rails (~> 4.3) - kaminari (~> 1.1) + kaminari (~> 1.2, >= 1.2.1) loofah (~> 2.3.1) mini_magick (~> 4.9) mustache (~> 1.1.0) nobspw (~> 0.6.0) - omniauth (~> 1.9) + omniauth (= 1.9.0) omniauth-facebook (~> 5.0) omniauth-google-oauth2 (~> 0.7) omniauth-rails_csrf_protection (~> 0.1) @@ -225,15 +231,16 @@ GEM pg (~> 1.1.4, < 2) pg_search (~> 2.2) premailer-rails (~> 1.10) - rack (~> 2.0) + rack (>= 2.0.8) rack-attack (~> 6.0) - rails (>= 5.2, < 6.0.x) + rails (>= 5.2.4.3, < 6.0.x) rails-i18n (~> 5.0) rectify (~> 0.13.0) redis (~> 4.1) rubyzip (~> 2.0) - sassc (~> 1.12, >= 1.12.1) - sassc-rails (~> 1.3) + sassc (~> 2.3.0) + sassc-rails (~> 2.1.2) + seven_zip_ruby (~> 1.2, >= 1.2.2) social-share-button (~> 1.2, >= 1.2.1) spreadsheet (~> 1.2) sprockets (~> 3.7, < 4) @@ -242,83 +249,84 @@ GEM uglifier (~> 4.1) valid_email2 (~> 2.1) wisper (~> 2.0) - decidim-debates (0.20.0) - decidim-comments (= 0.20.0) - decidim-core (= 0.20.0) - kaminari (~> 1.1) + decidim-debates (0.22.0) + decidim-comments (= 0.22.0) + decidim-core (= 0.22.0) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-dev (0.20.0) + decidim-dev (0.22.0) byebug (~> 11.0) capybara (~> 3.24) db-query-matchers (~> 0.9.0) - decidim (= 0.20.0) + decidim (= 0.22.0) erb_lint (~> 0.0.28) factory_bot_rails (~> 4.8) i18n-tasks (~> 0.9.18) - mdl (~> 0.5.0) - nokogiri (>= 1.10.4) - puma (~> 3.12) + mdl (~> 0.10) + nokogiri (>= 1.10.8) + puma (>= 4.3) rails-controller-testing (~> 1.0) rspec-cells (~> 0.3.4) rspec-html-matchers (~> 0.9.1) rspec-rails (~> 3.7) + rspec-retry (~> 0.6.2) rspec_junit_formatter (~> 0.3.0) rubocop (~> 0.71.0) rubocop-rails (~> 2.0) rubocop-rspec (~> 1.21) selenium-webdriver (~> 3.142) - simplecov (~> 0.16) + simplecov (~> 0.18.5) + simplecov-cobertura (~> 1.3.1) system_test_html_screenshots (~> 0.1.1) webmock (~> 3.6) wisper-rspec (~> 1.0) - decidim-forms (0.20.0) - decidim-core (= 0.20.0) - decidim-generators (0.20.0) - decidim-core (= 0.20.0) - decidim-meetings (0.20.0) + decidim-forms (0.22.0) + decidim-core (= 0.22.0) + decidim-generators (0.22.0) + decidim-core (= 0.22.0) + decidim-meetings (0.22.0) cells-erb (~> 0.1.0) cells-rails (~> 0.0.9) - decidim-core (= 0.20.0) - decidim-forms (= 0.20.0) + decidim-core (= 0.22.0) + decidim-forms (= 0.22.0) httparty (~> 0.17) icalendar (~> 2.5) jquery-tmpl-rails (~> 1.1) - kaminari (~> 1.1) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-pages (0.20.0) - decidim-core (= 0.20.0) - decidim-participatory_processes (0.20.0) - decidim-core (= 0.20.0) - decidim-proposals (0.20.0) + decidim-pages (0.22.0) + decidim-core (= 0.22.0) + decidim-participatory_processes (0.22.0) + decidim-core (= 0.22.0) + decidim-proposals (0.22.0) acts_as_list (~> 0.9) cells-erb (~> 0.1.0) cells-rails (~> 0.0.9) - decidim-comments (= 0.20.0) - decidim-core (= 0.20.0) - diffy (~> 3.3) + decidim-comments (= 0.22.0) + decidim-core (= 0.22.0) doc2text (~> 0.4.2) - kaminari (~> 1.1) + kaminari (~> 1.2, >= 1.2.1) ransack (~> 2.1.1) redcarpet (~> 3.4) - decidim-sortitions (0.20.0) - decidim-admin (= 0.20.0) - decidim-comments (= 0.20.0) - decidim-core (= 0.20.0) - decidim-proposals (= 0.20.0) - decidim-surveys (0.20.0) - decidim-core (= 0.20.0) - decidim-forms (= 0.20.0) - decidim-system (0.20.0) + decidim-sortitions (0.22.0) + decidim-admin (= 0.22.0) + decidim-comments (= 0.22.0) + decidim-core (= 0.22.0) + decidim-proposals (= 0.22.0) + decidim-surveys (0.22.0) + decidim-core (= 0.22.0) + decidim-forms (= 0.22.0) + decidim-system (0.22.0) active_link_to (~> 1.0) - decidim-core (= 0.20.0) + decidim-core (= 0.22.0) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 1.7) jquery-rails (~> 4.3) - sassc (~> 1.12, >= 1.12.1) - sassc-rails (~> 1.3) - decidim-verifications (0.20.0) - decidim-core (= 0.20.0) + sassc (~> 2.3.0) + sassc-rails (~> 2.1.2) + decidim-verifications (0.22.0) + decidim-core (= 0.22.0) declarative-builder (0.1.0) declarative-option (< 0.2.0) declarative-option (0.1.0) @@ -370,13 +378,13 @@ GEM faraday (1.1.0) multipart-post (>= 1.2, < 3) ruby2_keywords - ffi (1.9.25) + ffi (1.13.1) file_validators (2.3.0) activemodel (>= 3.2) mime-types (>= 1.0) - foundation-rails (6.4.3.0) + foundation-rails (6.6.2.0) railties (>= 3.1.0) - sass (>= 3.3.0, < 3.5) + sass (>= 3.3.0) sprockets-es6 (>= 0.9.0) foundation_rails_helper (3.0.0) actionpack (>= 4.1, < 6.0) @@ -392,7 +400,7 @@ GEM sprockets-rails graphql (1.11.6) hashdiff (1.0.1) - hashie (4.1.0) + hashie (3.6.0) highline (2.0.3) html_tokenizer (0.0.7) htmlentities (4.3.4) @@ -441,7 +449,10 @@ GEM activerecord kaminari-core (= 1.2.1) kaminari-core (1.2.1) - kramdown (1.17.0) + kramdown (2.3.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) launchy (2.5.0) addressable (~> 2.7) letter_opener (1.7.0) @@ -460,10 +471,12 @@ GEM mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) - mdl (0.5.0) - kramdown (~> 1.12, >= 1.12.0) - mixlib-cli (~> 1.7, >= 1.7.0) - mixlib-config (~> 2.2, >= 2.2.1) + mdl (0.11.0) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.1) + mixlib-cli (~> 2.1, >= 2.1.1) + mixlib-config (>= 2.2.1, < 4) + mixlib-shellout method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) @@ -473,9 +486,11 @@ GEM mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.14.2) - mixlib-cli (1.7.0) - mixlib-config (2.2.18) + mixlib-cli (2.1.8) + mixlib-config (3.0.9) tomlrb + mixlib-shellout (3.1.7) + chef-utils msgpack (1.3.3) multi_json (1.15.0) multi_xml (0.6.0) @@ -493,8 +508,8 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - omniauth (1.9.1) - hashie (>= 3.4.6) + omniauth (1.9.0) + hashie (>= 3.4.6, < 3.7.0) rack (>= 1.6.2, < 3) omniauth-facebook (5.0.0) omniauth-oauth2 (~> 1.2) @@ -533,7 +548,8 @@ GEM actionmailer (>= 3) premailer (~> 1.7, >= 1.7.9) public_suffix (4.0.6) - puma (3.12.6) + puma (4.3.6) + nio4r (~> 2.0) rack (2.2.3) rack-attack (6.3.1) rack (>= 1.0, < 3) @@ -601,6 +617,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) + rexml (3.2.4) rspec (3.9.0) rspec-core (~> 3.9.0) rspec-expectations (~> 3.9.0) @@ -627,6 +644,8 @@ GEM rspec-expectations (~> 3.9.0) rspec-mocks (~> 3.9.0) rspec-support (~> 3.9.0) + rspec-retry (0.6.2) + rspec-core (> 3.3) rspec-support (3.9.4) rspec_junit_formatter (0.3.0) rspec-core (>= 2, < 4, != 2.12.0) @@ -646,24 +665,29 @@ GEM ruby-progressbar (1.10.1) ruby2_keywords (0.0.2) rubyzip (2.0.0) - sass (3.4.25) - sassc (1.12.1) - ffi (~> 1.9.6) - sass (>= 3.3.0) - sassc-rails (1.3.0) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sassc (2.3.0) + ffi (~> 1.9) + sassc-rails (2.1.2) railties (>= 4.0.0) - sass - sassc (~> 1.9) - sprockets (> 2.11) + sassc (>= 2.0) + sprockets (> 3.0) sprockets-rails tilt searchlight (4.1.0) selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - simplecov (0.19.1) + seven_zip_ruby (1.3.0) + simplecov (0.18.5) docile (~> 1.1) simplecov-html (~> 0.11) + simplecov-cobertura (1.3.1) + simplecov (~> 0.8) simplecov-html (0.12.3) smart_properties (1.15.0) social-share-button (1.2.3) @@ -740,13 +764,13 @@ DEPENDENCIES bootsnap (~> 1.3) byebug (~> 11.0) codecov - decidim (= 0.20.0) - decidim-dev (= 0.20.0) + decidim (= 0.22.0) + decidim-dev (= 0.22.0) decidim-direct_verifications! faker (~> 1.9) letter_opener_web (~> 1.3) listen (~> 3.1) - puma (~> 3.0) + puma (~> 4.0) spring (~> 2.0) spring-watcher-listen (~> 2.0) uglifier (~> 4.1) diff --git a/app/controllers/decidim/direct_verifications/verification/admin/authorizations_controller.rb b/app/controllers/decidim/direct_verifications/verification/admin/authorizations_controller.rb index 9c92666..9cec560 100644 --- a/app/controllers/decidim/direct_verifications/verification/admin/authorizations_controller.rb +++ b/app/controllers/decidim/direct_verifications/verification/admin/authorizations_controller.rb @@ -22,7 +22,12 @@ def destroy private def collection - Decidim::Authorization.where(name: "direct_verifications").includes(:user) + # Decidim::Verifications::Authorizations Query + Decidim::Verifications::Authorizations.new( + organization: current_organization, + name: "direct_verifications", + granted: true + ).query end def authorization diff --git a/app/controllers/decidim/direct_verifications/verification/admin/direct_verifications_controller.rb b/app/controllers/decidim/direct_verifications/verification/admin/direct_verifications_controller.rb index f0e1aa3..079de91 100644 --- a/app/controllers/decidim/direct_verifications/verification/admin/direct_verifications_controller.rb +++ b/app/controllers/decidim/direct_verifications/verification/admin/direct_verifications_controller.rb @@ -18,7 +18,7 @@ def create enforce_permission_to :create, :authorization @userslist = params[:userlist] - @processor = UserProcessor.new(current_organization, current_user) + @processor = UserProcessor.new(current_organization, current_user, session) @processor.emails = parser_class.new(@userslist).to_h @processor.authorization_handler = current_authorization_handler @stats = UserStats.new(current_organization) diff --git a/lib/decidim/direct_verifications/user_processor.rb b/lib/decidim/direct_verifications/user_processor.rb index befa6e0..156fcfe 100644 --- a/lib/decidim/direct_verifications/user_processor.rb +++ b/lib/decidim/direct_verifications/user_processor.rb @@ -3,16 +3,17 @@ module Decidim module DirectVerifications class UserProcessor - def initialize(organization, current_user) + def initialize(organization, current_user, session) @organization = organization @current_user = current_user @authorization_handler = :direct_verifications @errors = { registered: [], authorized: [], revoked: [] } @processed = { registered: [], authorized: [], revoked: [] } @emails = {} + @session = session end - attr_reader :organization, :current_user, :errors, :processed + attr_reader :organization, :current_user, :session, :errors, :processed attr_accessor :authorization_handler, :emails def register_users @@ -50,7 +51,7 @@ def authorize_users next unless !auth.granted? || auth.expired? - Verification::ConfirmUserAuthorization.call(auth, authorize_form(u)) do + Verification::ConfirmUserAuthorization.call(auth, authorize_form(u), session) do on(:ok) do add_processed :authorized, email end diff --git a/lib/decidim/direct_verifications/version.rb b/lib/decidim/direct_verifications/version.rb index 6c55ec4..850ec44 100644 --- a/lib/decidim/direct_verifications/version.rb +++ b/lib/decidim/direct_verifications/version.rb @@ -3,8 +3,8 @@ module Decidim # This holds the decidim-direct_verifications version. module DirectVerifications - VERSION = "0.20" - DECIDIM_VERSION = "0.20.0" - MIN_DECIDIM_VERSION = ">= 0.17.0" + VERSION = "0.22" + DECIDIM_VERSION = "0.22.0" + MIN_DECIDIM_VERSION = ">= 0.22.0" end end diff --git a/spec/commands/decidim/direct_verifications/verification/confirm_user_authorization_spec.rb b/spec/commands/decidim/direct_verifications/verification/confirm_user_authorization_spec.rb index b77c52f..f0225f6 100644 --- a/spec/commands/decidim/direct_verifications/verification/confirm_user_authorization_spec.rb +++ b/spec/commands/decidim/direct_verifications/verification/confirm_user_authorization_spec.rb @@ -7,8 +7,9 @@ module DirectVerifications module Verification module Admin describe ConfirmUserAuthorization do - subject { described_class.new(authorization, form) } + subject { described_class.new(authorization, form, session) } + let(:session) { double(:session) } let(:organization) do create(:organization, available_authorizations: ["direct_verifications"]) end diff --git a/spec/lib/decidim/direct_verifications/user_processor_spec.rb b/spec/lib/decidim/direct_verifications/user_processor_spec.rb index 3031cc0..f7a3ace 100644 --- a/spec/lib/decidim/direct_verifications/user_processor_spec.rb +++ b/spec/lib/decidim/direct_verifications/user_processor_spec.rb @@ -5,9 +5,10 @@ module Decidim module DirectVerifications describe UserProcessor do - subject { described_class.new(organization, user) } + subject { described_class.new(organization, user, session) } let(:user) { create(:user, :confirmed, :admin, organization: organization) } + let(:session) { double(:session) } let(:organization) do create(:organization, available_authorizations: ["direct_verifications"]) end diff --git a/spec/system/decidim/direct_verifications/admin/admin_manages_imported_authorizations_spec.rb b/spec/system/decidim/direct_verifications/admin/admin_manages_imported_authorizations_spec.rb index 3ca8563..44a3a1e 100644 --- a/spec/system/decidim/direct_verifications/admin/admin_manages_imported_authorizations_spec.rb +++ b/spec/system/decidim/direct_verifications/admin/admin_manages_imported_authorizations_spec.rb @@ -5,8 +5,10 @@ describe "Admin manages imported authorizations", type: :system do let(:organization) { create(:organization) } let(:user) { create(:user, :admin, :confirmed, organization: organization) } + let(:out_of_scope_user) { create(:user, :confirmed) } - let!(:authorization) { create(:authorization, :direct_verification) } + let!(:authorization) { create(:authorization, :direct_verification, user: user) } + let!(:out_of_scope_authorization) { create(:authorization, :direct_verification, user: out_of_scope_user) } let!(:non_direct_authorization) { create(:authorization) } let(:scope) { "decidim.direct_verifications.verification.admin" } @@ -22,10 +24,10 @@ context "when listing authorizations" do it "lists authorizations imported through direct_verifications" do within "table thead" do - expect(page).to have_content(I18n.t("authorizations.index.name", scope: scope).upcase) - expect(page).to have_content(I18n.t("authorizations.index.metadata", scope: scope).upcase) - expect(page).to have_content(I18n.t("authorizations.index.user_name", scope: scope).upcase) - expect(page).to have_content(I18n.t("authorizations.index.created_at", scope: scope).upcase) + expect(page).to have_content(I18n.t("authorizations.index.name", scope: scope)) + expect(page).to have_content(I18n.t("authorizations.index.metadata", scope: scope)) + expect(page).to have_content(I18n.t("authorizations.index.user_name", scope: scope)) + expect(page).to have_content(I18n.t("authorizations.index.created_at", scope: scope)) end within "tr[data-authorization-id=\"#{authorization.id}\"]" do @@ -36,6 +38,7 @@ end expect(page).not_to have_content(non_direct_authorization.name) + expect(page).not_to have_content(out_of_scope_authorization.user.name) end it "lets users navigate to stats and new import" do