Comments (2)
Hey @kleber-gueriero!
Could you please provide a code example and a test example for this exception?'
P.S. Sorry for such a late response.
from abstract_notifier.
Edit
nvm, I didn't realize that you can add .twice
🙏
What I originally wrote
I can see a similar issue with `have_sent_notification` matcher as well.I have two callbacks where each of them create notifications.
Basically, when I have a test like
the test
RSpec.describe Post, type: :model do
describe 'notifications' do
context 'when new post is published' do
it { expect { create(:post) }.to have_sent_notification }
end
end
end
example model
class Post < ActiveRecord
after_create :notify_can_see_posts
after_create :notify_new_post
def notify_can_see_posts
FromAdminNotifier.send_can_see_posts.notify_now
end
def notify_new_post
NewPostNotifier.created(self).notify_now
end
end
example notifiers
# frozen_string_literal: true
class NewPostNotifier < ApplicationNotifier
def created(post)
notification(
title: 'New post!',
body: "#{post.title}",
)
end
end
class FromAdminNotifier < ApplicationNotifier
def send_can_see_posts()
notification(
title: 'Thanks for your post!',
body: 'Thank you for your submission. Now you can see what others have posted on the platform!',
)
end
end
So creating a post sends two notifications. One to the user who have submitted to tell them that they can now see others post (we have some exclusive thread page like that), and another to rest of the users who have already submitted a post to tell them that there's a new post in the app.
When one action sends two or more notifications, the matcher fails.
from abstract_notifier.
Related Issues (6)
- RSpec matchers doesn't work HOT 1
- Option to disable default `notifier` line with ActiveDelivery? HOT 4
- An error raised in an ActiveDelivery line behaves differently than one raised in an ActiveMailer line HOT 5
- Wrap around notification call similar to the around_action HOT 1
- Ruby 2.7/3.0 support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abstract_notifier.