|
3 | 3 | RSpec.describe Notification, type: :model do |
4 | 4 | let(:user) { create(:user) } |
5 | 5 | let(:user2) { create(:user) } |
6 | | - let(:user3) { create(:user) } |
7 | | - let(:organization) { create(:organization) } |
| 6 | + let_it_be(:user3) { create(:user) } |
| 7 | + let_it_be(:organization) { create(:organization) } |
8 | 8 | let(:article) { create(:article, user_id: user.id, page_views_count: 4000, positive_reactions_count: 70) } |
9 | 9 | let(:follow_instance) { user.follow(user2) } |
10 | 10 |
|
|
86 | 86 | end |
87 | 87 |
|
88 | 88 | it "does not send a notification to the author of the article if the commenter is the author" do |
89 | | - comment = create(:comment, user: user, commentable: article) |
| 89 | + comment = build_stubbed(:comment, user: user, commentable: article) |
90 | 90 | Notification.send_new_comment_notifications_without_delay(comment) |
91 | 91 | expect(user.notifications.count).to eq 0 |
92 | 92 | end |
93 | 93 |
|
94 | 94 | it "does not send a notification to the author of the comment" do |
95 | | - comment = create(:comment, user: user2, commentable: article) |
| 95 | + comment = build_stubbed(:comment, user: user2, commentable: article) |
96 | 96 | Notification.send_new_comment_notifications_without_delay(comment) |
97 | 97 | expect(user2.notifications.count).to eq 0 |
98 | 98 | end |
99 | 99 |
|
100 | 100 | it "sends a notification to the organization" do |
101 | | - org = create(:organization) |
| 101 | + org = build_stubbed(:organization) |
102 | 102 | user.update(organization: org) |
103 | 103 | article.update(organization: org) |
104 | 104 | comment = create(:comment, user: user2, commentable: article) |
|
110 | 110 | context "when the author of the article is not subscribed" do |
111 | 111 | it "does not send a notification to the author of the article" do |
112 | 112 | article.update(receive_notifications: false) |
113 | | - comment = create(:comment, user: user2, commentable: article) |
| 113 | + comment = build_stubbed(:comment, user: user2, commentable: article) |
114 | 114 | Notification.send_new_comment_notifications_without_delay(comment) |
115 | 115 | expect(user.notifications.count).to eq 0 |
116 | 116 | end |
|
120 | 120 | it "does not send a notification to the author of the comment" do |
121 | 121 | parent_comment = create(:comment, user: user2, commentable: article) |
122 | 122 | parent_comment.update(receive_notifications: false) |
123 | | - child_comment = create(:comment, user: user, commentable: article, ancestry: parent_comment.id.to_s) |
| 123 | + child_comment = build_stubbed(:comment, user: user, commentable: article, ancestry: parent_comment.id.to_s) |
124 | 124 | Notification.send_new_comment_notifications_without_delay(child_comment) |
125 | 125 | expect(user2.notifications.count).to eq 0 |
126 | 126 | end |
|
147 | 147 | it "does not send a notification to the author of a comment" do |
148 | 148 | comment = create(:comment, user: user2, commentable: article) |
149 | 149 | comment.update(receive_notifications: false) |
150 | | - reaction = create(:reaction, reactable: comment, user: user) |
| 150 | + reaction = build_stubbed(:reaction, reactable: comment, user: user) |
151 | 151 | Notification.send_reaction_notification_without_delay(reaction, reaction.reactable.user) |
152 | 152 | expect(user2.notifications.count).to eq 0 |
153 | 153 | end |
154 | 154 |
|
155 | 155 | it "does not send a notification to the author of an article" do |
156 | 156 | article.update(receive_notifications: false) |
157 | | - reaction = create(:reaction, reactable: article, user: user2) |
| 157 | + reaction = build_stubbed(:reaction, reactable: article, user: user2) |
158 | 158 | Notification.send_reaction_notification_without_delay(reaction, reaction.reactable.user) |
159 | 159 | expect(user.notifications.count).to eq 0 |
160 | 160 | end |
|
0 commit comments