Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed Oct 1, 2024
2 parents 17d6086 + 67904c5 commit 874fc88
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

module Decidim
module Privacy
module Admin
module CreateParticipatorySpacePrivateUserExtensions
extend ActiveSupport::Concern

included do
private

def existing_user
return @existing_user if defined?(@existing_user)

@existing_user = Decidim::User.entire_collection.find_by(
email: form.email.downcase,
organization: private_user_to.organization
)

InviteUserAgain.call(@existing_user, invitation_instructions) if @existing_user&.invitation_pending?
@existing_user
end
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def authors
authors = authors.flat_map do |klass, ids|
klass.constantize.where(id: ids)
end
@authors = authors.filter { |author| author.is_a?(Decidim::User) && !author.published_at.nil? }.compact.uniq
@authors = authors.filter { |author| !author.is_a?(Decidim::User) || author.published_at.present? }.compact.uniq
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/decidim/privacy/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class Engine < ::Rails::Engine
# The following changes are related to "Ask old password for changing email/password(PR #11737)"
# These changes should be removed once it has been backported to v.27
Decidim::UpdateAccount.include(Decidim::Privacy::UpdateAccountExtensions)
Decidim::Admin::CreateParticipatorySpacePrivateUser.include(
Decidim::Privacy::Admin::CreateParticipatorySpacePrivateUserExtensions
)

# controllers
Decidim::ApplicationController.include(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require "spec_helper"

describe Decidim::Privacy::Admin::CreateParticipatorySpacePrivateUserExtensions do
subject { Decidim::Admin::CreateParticipatorySpacePrivateUser.new(form, current_user, privatable_to, via_csv:) }

let!(:via_csv) { false }
let!(:privatable_to) { create(:participatory_process) }
let!(:email) { "[email protected]" }
let!(:name) { "Weird Guy" }
let!(:user) { create(:user, email: "[email protected]", organization: privatable_to.organization) }
let!(:current_user) { create(:user, email: "[email protected]", organization: privatable_to.organization) }
let!(:form) do
double(
invalid?: invalid,
delete_current_private_participants?: delete,
email:,
current_user:,
name:
)
end
let(:delete) { false }
let(:invalid) { false }

it "finds private users" do
expect(subject.send(:existing_user)).to eq(user)
end
end
33 changes: 33 additions & 0 deletions spec/system/admin/proposals_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require "spec_helper"
require "decidim/privacy/test/rspec_support/component"

describe "Proposals" do
include ComponentTestHelper

let!(:organization) { create(:organization) }
let!(:participatory_process) { create(:participatory_process, :with_steps, organization:) }
let!(:user) { create(:user, :admin, :confirmed, organization:) }
let!(:proposal) { create(:proposal, :official, :published, component:) }

before do
switch_to_host(organization.host)
login_as user, scope: :user
visit decidim_admin.root_path
end

context "when trying to edit an official proposal" do
let!(:component) { create(:proposal_component, :with_creation_enabled, participatory_space: participatory_process) }

it "lets the admin user to edit" do
click_on "Processes"
click_on participatory_process.title["en"]
click_on "Proposals"
expect(page).to have_content(proposal.title["en"])
within("a.action-icon--edit-proposal") do
expect(page).to have_css('svg[aria-label="Edit proposal"]')
end
end
end
end

0 comments on commit 874fc88

Please sign in to comment.