-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Refactor Podcasts Bust Cache job #5421
Refactor Podcasts Bust Cache job #5421
Conversation
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.
@maykonmenezes thanks for another solid PR!!!
spec/models/podcast_spec.rb
Outdated
it "triggers cache busting on save" do | ||
expect { build(:podcast).save }.to have_enqueued_job.on_queue("podcasts_bust_cache").once | ||
podcast.save | ||
expect(Podcasts::BustCacheWorker).to have_received(:perform_async).with(podcast.path) |
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.
just a note: this should probably check the job is in the queue with the sidekiq test helpers, instead of using mocks
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.
Got it, I will change it ;)
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.
Lets do this spec like you did the one above and I think this will be ready to go!!!
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.
done!
@mstruve is this one safe to remove the old job and spec in the same PR? Looks like this is called in an Otherwise, LGTM 💯 |
I believe this one is good bc
Is that logic sound? Did I miss any use cases? |
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.
It makes sense to me! Thanks, @mstruve and @maykonmenezes! 💯
before do | ||
allow(Pages::BustCacheWorker).to receive(:perform_async) | ||
end | ||
let(:page) { create(:page) } |
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.
shouldn't this be a build(:page)
? the reason why this test passes is because create also runs save
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.
I don't think it matters bc that block below asserts that a new job is enqueued on save. Whether it's a new record or already existing one is inconsequential
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.
Good job @maykonmenezes!
What type of PR is this? (check all applicable)
Description
Migrated Podcasts::BustCacheJob to a side worker
Related Tickets & Documents
#5305
Mobile & Desktop Screenshots/Recordings (if there are UI changes)
Added to documentation?
[optional] What gif best describes this PR or how it makes you feel?