|
369 | 369 | fab!(:post_2) { Fabricate(:post, topic: topic_2) } |
370 | 370 | fab!(:post_3) { Fabricate(:post, topic: topic_3) } |
371 | 371 |
|
372 | | - before do |
373 | | - sign_in(admin) |
| 372 | + describe "when user cannot assign" do |
| 373 | + it "ignores the assign filter" do |
| 374 | + add_to_assign_allowed_group(user) |
| 375 | + |
| 376 | + Assigner.new(topic_1, user).assign(user) |
| 377 | + |
| 378 | + get "/filter", params: { q: "assigned:#{user.username_lower}", format: :json } |
| 379 | + |
| 380 | + expect(response.status).to eq(200) |
| 381 | + expect( |
| 382 | + response.parsed_body.dig("topic_list", "topics").map { _1["id"] }, |
| 383 | + ).to contain_exactly(topic_1.id, topic_2.id, topic_3.id) |
| 384 | + end |
374 | 385 | end |
375 | 386 |
|
376 | | - it "filters topics by assigned user" do |
377 | | - add_to_assign_allowed_group(user) |
| 387 | + describe "when user can assign" do |
| 388 | + before { sign_in(admin) } |
378 | 389 |
|
379 | | - Assigner.new(topic_1, admin).assign(user) |
| 390 | + it "filters topics by assigned user" do |
| 391 | + add_to_assign_allowed_group(user) |
380 | 392 |
|
381 | | - get "/filter", params: { q: "assigned:#{user.username_lower}", format: :json } |
| 393 | + Assigner.new(topic_1, admin).assign(user) |
382 | 394 |
|
383 | | - expect(response.status).to eq(200) |
384 | | - expect(response.parsed_body.dig("topic_list", "topics").map { _1["id"] }).to contain_exactly(topic_1.id) |
385 | | - end |
| 395 | + get "/filter", params: { q: "assigned:#{user.username_lower}", format: :json } |
| 396 | + |
| 397 | + expect(response.status).to eq(200) |
| 398 | + expect( |
| 399 | + response.parsed_body.dig("topic_list", "topics").map { _1["id"] }, |
| 400 | + ).to contain_exactly(topic_1.id) |
| 401 | + end |
386 | 402 |
|
387 | | - it "filters topics by assigned group" do |
388 | | - Assigner.new(topic_2, admin).assign(group) |
| 403 | + it "filters topics by assigned group" do |
| 404 | + Assigner.new(topic_2, admin).assign(group) |
389 | 405 |
|
390 | | - get "/filter", params: { q: "assigned:#{group.name}", format: :json } |
| 406 | + get "/filter", params: { q: "assigned:#{group.name}", format: :json } |
391 | 407 |
|
392 | | - expect(response.status).to eq(200) |
393 | | - expect(response.parsed_body.dig("topic_list", "topics").map { _1["id"] }).to contain_exactly(topic_2.id) |
| 408 | + expect(response.status).to eq(200) |
| 409 | + expect( |
| 410 | + response.parsed_body.dig("topic_list", "topics").map { _1["id"] }, |
| 411 | + ).to contain_exactly(topic_2.id) |
| 412 | + end |
394 | 413 | end |
395 | 414 | end |
396 | 415 | end |
0 commit comments