-
Notifications
You must be signed in to change notification settings - Fork 37
TAN-5756 Emails flagging and new comment bugs #12407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
5103e47
30eaaa3
71728d4
14748c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,62 @@ | |
| end | ||
| end | ||
|
|
||
| describe '#generate_commands' do | ||
| let(:recipient) { create(:user) } | ||
| let(:author) { create(:user, first_name: 'Rea', last_name: 'Xion') } | ||
| let(:comment) { create(:comment, body_multiloc: { 'en' => 'Example comment.' }, author:) } | ||
| let(:campaign) { create(:new_comment_for_admin_campaign) } | ||
| let(:activity) { create(:activity, item: comment, action: 'created') } | ||
|
|
||
| it 'generates a command with the desired payload and tracked content' do | ||
| command = campaign.generate_commands(recipient:, activity:).first | ||
|
|
||
| expect(command).to match( | ||
| event_payload: a_hash_including( | ||
| initiating_user_first_name: 'Rea', | ||
| initiating_user_last_name: 'Xion', | ||
| comment_author_name: 'Rea Xion', | ||
| comment_body_multiloc: { 'en' => 'Example comment.' }, | ||
| comment_url: "http://example.org/en/ideas/#{comment.idea.slug}", | ||
| idea_published_at: comment.idea.published_at.iso8601, | ||
| idea_title_multiloc: comment.idea.title_multiloc, | ||
| idea_author_name: comment.idea.author_name | ||
| ) | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| describe 'filter_recipient' do | ||
| let(:idea) { create(:idea) } | ||
| let(:author) { create(:user, first_name: 'Rea', last_name: 'Xion') } | ||
| let(:comment) { create(:comment, body_multiloc: { 'en' => 'Example comment.' }, author:, idea:) } | ||
| let(:campaign) { create(:new_comment_for_admin_campaign) } | ||
| let(:activity) { create(:activity, item: comment, action: 'created') } | ||
| let!(:resident) { create(:user) } | ||
| let!(:admin) { create(:admin) } | ||
| let!(:moderator) { create(:project_moderator, projects: [idea.project]) } | ||
|
|
||
| it 'filters out moderators' do | ||
| expect(campaign.filter_recipient(User.all, activity:).ids).to match_array([admin.id, moderator.id]) | ||
| end | ||
|
||
|
|
||
| context 'when the author is a moderator' do | ||
| let(:author) { create(:project_moderator, projects: [idea.project]) } | ||
|
|
||
| it 'filters out no one if the author is a moderator' do | ||
|
||
| expect(campaign.filter_recipient(User.all, activity:).ids).to eq [] | ||
| end | ||
| end | ||
|
|
||
| context 'when there is no author' do | ||
| let(:author) { nil } | ||
|
|
||
| it 'filters out moderators' do | ||
|
||
| expect(campaign.filter_recipient(User.all, activity:).ids).to match_array([admin.id, moderator.id]) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| describe 'apply_recipient_filters' do | ||
| let(:campaign) { build(:new_comment_for_admin_campaign) } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄