-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Don't send comment email to suspended or inactive users. #1363
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
da1183e
Don't send comment email to suspended or inactive users.
steveyken 76f58e5
Update app/models/polymorphic/comment.rb
CloCkWeRX 52fdc53
Fix broken spec
steveyken 25b42a4
Moved emailable logic to user model. Adjust AREL clause to only load …
steveyken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -15,7 +15,8 @@ | |
password: 'password', | ||
password_confirmation: 'password', | ||
email: '[email protected]', | ||
sign_in_count: 0 | ||
sign_in_count: 0, | ||
confirmed_at: nil | ||
end | ||
|
||
scenario 'without confirmation' do | ||
|
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 |
---|---|---|
|
@@ -42,4 +42,36 @@ | |
expect(entity.subscribed_users).to include(user.id) | ||
end | ||
end | ||
|
||
describe "notify_subscribers" do | ||
let(:subscriber) { create(:user) } | ||
let(:entity) { create(:lead, subscribed_users: [subscriber.id]) } | ||
before(:each) do | ||
allow(SubscriptionMailer).to receive_message_chain(:comment_notification, :deliver_later) | ||
end | ||
|
||
it "should notify subscribers when a comment is added" do | ||
Comment.create!(comment: "Hello", user: create(:user), commentable: entity) | ||
expect(SubscriptionMailer).to have_received(:comment_notification).with(subscriber, instance_of(Comment)) | ||
end | ||
|
||
it "should not notify the user who created the comment" do | ||
user = create(:user, confirmed_at: Time.now, email: "[email protected]") | ||
Comment.create!(comment: "Hello", user: user, commentable: entity) | ||
expect(SubscriptionMailer).not_to have_received(:comment_notification).with(user, instance_of(Comment)) | ||
end | ||
|
||
it "should not notify suspended users" do | ||
subscriber.update(suspended_at: Time.now) | ||
Comment.create!(comment: "Hello", user: create(:user), commentable: entity) | ||
expect(SubscriptionMailer).not_to have_received(:comment_notification).with(subscriber, instance_of(Comment)) | ||
end | ||
|
||
it "should not notify users awaiting approval" do | ||
subscriber.update(sign_in_count: 0, suspended_at: Time.now) | ||
allow(Setting).to receive(:user_signup).and_return(:not_allowed) | ||
Comment.create!(comment: "Hello", user: create(:user), commentable: entity) | ||
expect(SubscriptionMailer).not_to have_received(:comment_notification).with(subscriber, instance_of(Comment)) | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / Rubocop
Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax { :a => 1, :b => 2 }. Note test