-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...ands/concerns/decidim/privacy/admin/create_participatory_space_private_user_extensions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...concerns/decidim/privacy/admin/create_participatory_space_private_user_extensions_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |