@@ -374,4 +374,24 @@ describe AgentsController do |
||
| 374 | 374 |
} |
| 375 | 375 |
end |
| 376 | 376 |
end |
| 377 |
+ |
|
| 378 |
+ describe "DELETE memory" do |
|
| 379 |
+ it "clears memory of the agent" do |
|
| 380 |
+ agent = agents(:bob_website_agent) |
|
| 381 |
+ agent.update!(memory: { "test" => 42 })
|
|
| 382 |
+ sign_in users(:bob) |
|
| 383 |
+ delete :destroy_memory, id: agent.to_param |
|
| 384 |
+ expect(agent.reload.memory).to eq({})
|
|
| 385 |
+ end |
|
| 386 |
+ |
|
| 387 |
+ it "does not clear memory of an agent not owned by the current user" do |
|
| 388 |
+ agent = agents(:jane_website_agent) |
|
| 389 |
+ agent.update!(memory: { "test" => 42 })
|
|
| 390 |
+ sign_in users(:bob) |
|
| 391 |
+ expect {
|
|
| 392 |
+ delete :destroy_memory, id: agent.to_param |
|
| 393 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
| 394 |
+ expect(agent.reload.memory).to eq({ "test" => 42})
|
|
| 395 |
+ end |
|
| 396 |
+ end |
|
| 377 | 397 |
end |