-
-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport 'User role is defined for digest notifications to scope tran…
…slations correctly' to v0.27 (#10738) * initial commit * notificationspec * shared-example * meeting-debate-specs-open * tests-unfinished * tests-finished * test-content-change * content-change * refactored-tests * moved-test-specific-shared-context-to-test * resolved-conflict --------- Co-authored-by: JoonasAapro <110532525+JoonasAapro@users.noreply.github.com> Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>
- Loading branch information
1 parent
bfd4800
commit e27da06
Showing
6 changed files
with
180 additions
and
0 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
33 changes: 33 additions & 0 deletions
33
decidim-core/lib/decidim/core/test/shared_examples/digest_mail_examples.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,33 @@ | ||
# frozen_string_literal: true | ||
|
||
shared_context "when sends the notification digest" do | ||
context "when daily notification mail" do | ||
let(:user) { create(:user, :admin, organization: organization, notifications_sending_frequency: "daily") } | ||
|
||
it_behaves_like "notification digest mail" | ||
end | ||
|
||
context "when weekly notification mail" do | ||
let(:user) { create(:user, :admin, organization: organization, notifications_sending_frequency: "weekly") } | ||
|
||
it_behaves_like "notification digest mail" | ||
end | ||
end | ||
|
||
shared_examples_for "notification digest mail" do | ||
context "when a notificable event takes place" do | ||
let!(:organization) { create(:organization) } | ||
let!(:participatory_space) { create(:participatory_process, organization: organization) } | ||
|
||
it "sends a notification to the user's email" do | ||
perform_enqueued_jobs do | ||
expect(command.call).to broadcast(:ok) | ||
Decidim::Notification.last.update(created_at: 1.day.ago) | ||
Decidim::EmailNotificationsDigestGeneratorJob.perform_now(user.id, user.notifications_sending_frequency) | ||
end | ||
|
||
expect(last_email_body.length).to be_positive | ||
expect(last_email_body).not_to include("translation missing") | ||
end | ||
end | ||
end |
50 changes: 50 additions & 0 deletions
50
decidim-debates/spec/events/decidim/debates/close_debate_event_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,50 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
module Decidim | ||
module Debates | ||
describe CloseDebateEvent do | ||
describe "notification digest mail" do | ||
let!(:component) { create(:debates_component, organization: organization, participatory_space: participatory_space) } | ||
let(:admin) { create(:user, :admin, organization: organization) } | ||
let!(:follow) { create(:follow, followable: record, user: user) } | ||
let(:params) do | ||
{ | ||
conclusions: "Example conclusion", | ||
id: record.id | ||
} | ||
end | ||
|
||
let!(:record) do | ||
create( | ||
:debate, | ||
component: component, | ||
title: { en: "Event notifier" }, | ||
description: { en: "This debate is for testing purposes" }, | ||
instructions: { en: "Use this debate for testing" } | ||
) | ||
end | ||
|
||
let(:form) { Decidim::Debates::Admin::CloseDebateForm.from_params(params).with_context(current_user: admin) } | ||
let!(:command) { Decidim::Debates::Admin::CloseDebate.new(form) } | ||
|
||
before do | ||
allow(command).to receive(:debate).and_return(record) | ||
end | ||
|
||
context "when daily notification mail" do | ||
let!(:user) { create(:user, organization: organization, notifications_sending_frequency: "daily") } | ||
|
||
it_behaves_like "notification digest mail" | ||
end | ||
|
||
context "when weekly notification mail" do | ||
let!(:user) { create(:user, organization: organization, notifications_sending_frequency: "weekly") } | ||
|
||
it_behaves_like "notification digest mail" | ||
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