FIX: Correct spec execution error.
This commit is contained in:
parent
acbad996f8
commit
4cdc5c64d5
|
@ -53,29 +53,27 @@ describe DiscourseSolved::AnswerController do
|
||||||
context "with plugin modifier" do
|
context "with plugin modifier" do
|
||||||
it "allows plugins to bypass rate limiting" do
|
it "allows plugins to bypass rate limiting" do
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
# Store the block in a variable so we can reference it for unregistration
|
||||||
# Register a modifier that disables rate limiting
|
block = ->(_, _) { false }
|
||||||
plugin_instance = DiscoursePluginRegistry.new
|
# Register modifier with proper parameters - plugin instance (self) and name
|
||||||
DiscoursePluginRegistry.register_modifier(
|
DiscoursePluginRegistry.register_modifier(
|
||||||
plugin_instance,
|
self,
|
||||||
:solved_answers_controller_run_rate_limiter
|
:solved_answers_controller_run_rate_limiter,
|
||||||
) do |_, _|
|
&block
|
||||||
false
|
)
|
||||||
end
|
|
||||||
|
|
||||||
# Multiple requests should succeed without rate limiting
|
|
||||||
post "/solution/accept.json", params: { id: solution_post.id }
|
post "/solution/accept.json", params: { id: solution_post.id }
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
post "/solution/accept.json", params: { id: solution_post.id }
|
post "/solution/accept.json", params: { id: solution_post.id }
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
|
# Unregister with the same plugin instance and block
|
||||||
# Clean up
|
DiscoursePluginRegistry.unregister_modifier(
|
||||||
DiscoursePluginRegistry.unregister_modifier(:solved_answers_controller_run_rate_limiter)
|
self, # plugin_instance parameter
|
||||||
|
:solved_answers_controller_run_rate_limiter, # name parameter
|
||||||
|
&block # same block used for registration
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#unaccept" do
|
describe "#unaccept" do
|
||||||
before do
|
before do
|
||||||
# Setup an accepted solution
|
# Setup an accepted solution
|
||||||
|
|
Loading…
Reference in New Issue