Skip to content

Commit

Permalink
get back previews implementation for user_role_checker file
Browse files Browse the repository at this point in the history
  • Loading branch information
ElviaBth committed Aug 13, 2024
1 parent 82e8c6d commit 43bbbb5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
21 changes: 15 additions & 6 deletions decidim-core/app/helpers/concerns/decidim/user_role_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,32 @@ def user_has_any_role?(user, participatory_space = nil)

def participatory_process_user_role?(user, participatory_process = nil)
return false unless Decidim.module_installed?(:participatory_processes)
return false unless participatory_process.is_a?(Decidim::ParticipatoryProcess)

Decidim::ParticipatoryProcessUserRole.exists?(user:, participatory_process:)
if participatory_process.is_a?(Decidim::ParticipatoryProcess)
Decidim::ParticipatoryProcessUserRole.exists?(user:, participatory_process:)
else
Decidim::ParticipatoryProcessUserRole.exists?(user:)
end
end

def assembly_user_role?(user, assembly = nil)
return false unless Decidim.module_installed?(:assemblies)
return false unless assembly.is_a?(Decidim::Assembly)

Decidim::AssemblyUserRole.exists?(user:, assembly:)
if assembly.is_a?(Decidim::Assembly)
Decidim::AssemblyUserRole.exists?(user:, assembly:)
else
Decidim::AssemblyUserRole.exists?(user:)
end
end

def conference_user_role?(user, conference = nil)
return false unless Decidim.module_installed?(:conferences)
return false unless conference.is_a?(Decidim::Conference)

Decidim::ConferenceUserRole.exists?(user:, conference:)
if conference.is_a?(Decidim::Conference)
Decidim::ConferenceUserRole.exists?(user:, conference:)
else
Decidim::ConferenceUserRole.exists?(user:)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@

context "when templates is not installed" do
before do
allow(Decidim).to receive(:module_installed?).and_call_original
allow(Decidim).to receive(:module_installed?).with(:templates).and_return(false)
visit current_path
page.find(".js-check-all").set(true)
Expand Down

0 comments on commit 43bbbb5

Please sign in to comment.