forked from decidim/decidim
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix organization multitenant issue with meeting's reminders (decidim#…
…12927) Co-authored-by: Alexandru Emil Lupu <[email protected]>
- Loading branch information
1 parent
012ea05
commit 8af2c82
Showing
2 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,11 @@ module Decidim::Meetings | |
end | ||
let(:intervals) { [3.days, 7.days] } | ||
let(:organization) { create(:organization) } | ||
let(:participatory_process) { create(:participatory_process, organization: organization) } | ||
let!(:component) { create(:component, :published, manifest_name: "meetings", participatory_space: participatory_process) } | ||
let(:participatory_space) { create(:participatory_process, organization: organization) } | ||
let!(:component) { create(:component, :published, manifest_name: "meetings", participatory_space: participatory_space) } | ||
let(:user) { create(:user, :admin, organization: organization, email: "[email protected]") } | ||
let!(:meeting) { create(:meeting, :published, component: component, author: user, start_time: start_time, end_time: end_time, closed_at: closed_at) } | ||
|
||
let(:closed_at) { nil } | ||
|
||
before do | ||
|
@@ -42,12 +43,49 @@ module Decidim::Meetings | |
end | ||
end | ||
|
||
context "and the meeting is not closed" do | ||
context "and the user meeting is not closed" do | ||
it "sends reminder" do | ||
expect(Decidim::Meetings::SendCloseMeetingReminderJob).to receive(:perform_later) | ||
|
||
expect { subject.generate }.to change(Decidim::Reminder, :count).by(1) | ||
end | ||
end | ||
|
||
context "and the official meeting is not closed" do | ||
let(:other_organization) { create(:organization) } | ||
let!(:user) { create(:user, :admin, organization: organization, email: "[email protected]") } | ||
let!(:other_admin) { create(:user, :admin, organization: other_organization, email: "[email protected]") } | ||
let!(:meeting) { create(:meeting, :published, :official, component: component, start_time: start_time, end_time: end_time, closed_at: closed_at) } | ||
|
||
it "sends reminder" do | ||
expect(Decidim::Meetings::SendCloseMeetingReminderJob).to receive(:perform_later) | ||
|
||
expect { subject.generate }.to change(Decidim::Reminder, :count).by(1) | ||
end | ||
|
||
context "and there are space admins" do | ||
context "and space admin is Participatory Process" do | ||
let(:participatory_space) { create(:participatory_process, organization: organization) } | ||
let!(:process_admin) { create(:process_admin, participatory_process: participatory_space) } | ||
|
||
it "sends reminder" do | ||
expect(Decidim::Meetings::SendCloseMeetingReminderJob).to receive(:perform_later).twice | ||
|
||
expect { subject.generate }.to change(Decidim::Reminder, :count).by(2) | ||
end | ||
end | ||
|
||
context "and space admin is Assembly" do | ||
let(:participatory_space) { create(:assembly, organization: organization) } | ||
let!(:process_admin) { create(:assembly_admin, assembly: participatory_space) } | ||
|
||
it "sends reminder" do | ||
expect(Decidim::Meetings::SendCloseMeetingReminderJob).to receive(:perform_later).twice | ||
|
||
expect { subject.generate }.to change(Decidim::Reminder, :count).by(2) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
|