Skip to content

Commit

Permalink
Add private user private process spec
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed Jun 14, 2024
1 parent 203cd8f commit a7f3fa1
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions spec/system/private_process_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

require "spec_helper"

describe "Private Participatory Processes", type: :system do
let!(:organization) { create(:organization) }
let!(:participatory_process) { create :participatory_process, :published, organization: organization }
let!(:private_participatory_process) { create :participatory_process, :published, organization: organization, private_space: true }
let!(:private_user) { create :user, :confirmed, organization: organization }
let!(:participatory_space_private_user) { create :participatory_space_private_user, user: private_user, privatable_to: private_participatory_process }

context "when user is logged in and is a \"private participatory space\" -user and also a private user" do
before do
switch_to_host(organization.host)
login_as private_user, scope: :user
visit decidim_participatory_processes.participatory_processes_path
end

it "lists private participatory processes" do
within "#processes-grid" do
within "#processes-grid h3" do
expect(page).to have_content("2")
end

expect(page).to have_content(translated(participatory_process.title, locale: :en))
expect(page).to have_content(translated(private_participatory_process.title, locale: :en))
expect(page).to have_selector(".card", count: 2)
end
end

it "links to the individual process page" do
first(".card__link", text: translated(private_participatory_process.title, locale: :en)).click

expect(page).to have_current_path decidim_participatory_processes.participatory_process_path(private_participatory_process)
expect(page).to have_content "This is a private process"
end
end
end

0 comments on commit a7f3fa1

Please sign in to comment.