Skip to content

Commit

Permalink
test: add tests for destroy private user and its follows
Browse files Browse the repository at this point in the history
  • Loading branch information
Stef-Rousset committed May 20, 2024
1 parent ede1275 commit d0cd212
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "spec_helper"
require "decidim/meetings/test/factories"

module Decidim::Admin
describe DestroyParticipatorySpacePrivateUser do
Expand Down Expand Up @@ -37,5 +38,33 @@ module Decidim::Admin
action_log = Decidim::ActionLog.last
expect(action_log.version).to be_nil
end

context "when assembly is not transparent" do
let(:normal_user) { create(:user, organization:) }
let(:assembly) { create(:assembly, :private, :opaque, :published, organization: user.organization) }
let!(:participatory_space_private_user) { create(:participatory_space_private_user, user: normal_user, privatable_to: assembly) }

context "and user follows assembly" do
let!(:follow) { create(:follow, followable: assembly, user: normal_user) }

it "destroys the follow" do
expect(Decidim::Follow.where(user: normal_user).count).to eq(1)
subject.call
expect(Decidim::Follow.where(user: normal_user).count).to eq(0)
end

context "and user follows meeting belonging to assembly" do
let(:meetings_component) { create(:component, manifest_name: "meetings", participatory_space: assembly) }
let(:meeting) { create(:meeting, component: meetings_component) }
let!(:second_follow) { create(:follow, followable: meeting, user: normal_user) }

it "destroys all follows" do
expect(Decidim::Follow.where(user: normal_user).count).to eq(2)
subject.call
expect(Decidim::Follow.where(user: normal_user).count).to eq(0)
end
end
end
end
end
end

0 comments on commit d0cd212

Please sign in to comment.