|
446 | 446 |
|
447 | 447 | sign_in(user)
|
448 | 448 | end
|
| 449 | + |
449 | 450 | describe "updating assignment status on solve when assignment_status_on_solve is set" do
|
450 | 451 | it "update all assignments to this status when a post is accepted" do
|
451 | 452 | assigner = Assigner.new(p1.topic, user)
|
|
483 | 484 | group.add(user_3)
|
484 | 485 |
|
485 | 486 | topic_question = Fabricate(:topic, user: user_1)
|
486 |
| - post_question = Fabricate(:post, topic: topic_question, user: user_1) |
487 | 487 |
|
488 |
| - user_2_response = Fabricate(:post, topic: topic_question, user: user_2) |
489 |
| - assigner = Assigner.new(topic_question, user_2) |
490 |
| - result = assigner.assign(user_2) |
| 488 | + Fabricate(:post, topic: topic_question, user: user_1) |
| 489 | + Fabricate(:post, topic: topic_question, user: user_2) |
| 490 | + |
| 491 | + result = Assigner.new(topic_question, user_2).assign(user_2) |
491 | 492 | expect(result[:success]).to eq(true)
|
492 | 493 |
|
493 | 494 | post_response = Fabricate(:post, topic: topic_question, user: user_3)
|
|
503 | 504 | expect(post_response.assignment.assigned_to_id).to eq(user_3.id)
|
504 | 505 | end
|
505 | 506 |
|
506 |
| - describe "assigned topic reminder" |
507 |
| - it "excludes solved topics when ignore_solved_topics_in_assigned_reminder is false" do |
508 |
| - other_topic = Fabricate(:topic, title: "Topic that should be there") |
509 |
| - post = Fabricate(:post, topic: other_topic, user: user) |
| 507 | + describe "assigned topic reminder" do |
| 508 | + it "excludes solved topics when ignore_solved_topics_in_assigned_reminder is false" do |
| 509 | + other_topic = Fabricate(:topic, title: "Topic that should be there") |
| 510 | + post = Fabricate(:post, topic: other_topic, user: user) |
510 | 511 |
|
511 |
| - other_topic2 = Fabricate(:topic, title: "Topic that should be there2") |
512 |
| - post2 = Fabricate(:post, topic: other_topic2, user: user) |
| 512 | + other_topic2 = Fabricate(:topic, title: "Topic that should be there2") |
| 513 | + post2 = Fabricate(:post, topic: other_topic2, user: user) |
513 | 514 |
|
514 |
| - Assigner.new(post.topic, user).assign(user) |
515 |
| - Assigner.new(post2.topic, user).assign(user) |
| 515 | + Assigner.new(post.topic, user).assign(user) |
| 516 | + Assigner.new(post2.topic, user).assign(user) |
516 | 517 |
|
517 |
| - reminder = PendingAssignsReminder.new |
518 |
| - topics = reminder.send(:assigned_topics, user, order: :asc) |
519 |
| - expect(topics.to_a.length).to eq(2) |
| 518 | + reminder = PendingAssignsReminder.new |
| 519 | + topics = reminder.send(:assigned_topics, user, order: :asc) |
| 520 | + expect(topics.to_a.length).to eq(2) |
520 | 521 |
|
521 |
| - DiscourseSolved.accept_answer!(post2, Discourse.system_user) |
522 |
| - topics = reminder.send(:assigned_topics, user, order: :asc) |
523 |
| - expect(topics.to_a.length).to eq(2) |
524 |
| - expect(topics).to include(other_topic2) |
| 522 | + DiscourseSolved.accept_answer!(post2, Discourse.system_user) |
| 523 | + topics = reminder.send(:assigned_topics, user, order: :asc) |
| 524 | + expect(topics.to_a.length).to eq(2) |
| 525 | + expect(topics).to include(other_topic2) |
525 | 526 |
|
526 |
| - SiteSetting.ignore_solved_topics_in_assigned_reminder = true |
527 |
| - topics = reminder.send(:assigned_topics, user, order: :asc) |
528 |
| - expect(topics.to_a.length).to eq(1) |
529 |
| - expect(topics).not_to include(other_topic2) |
530 |
| - expect(topics).to include(other_topic) |
| 527 | + SiteSetting.ignore_solved_topics_in_assigned_reminder = true |
| 528 | + topics = reminder.send(:assigned_topics, user, order: :asc) |
| 529 | + expect(topics.to_a.length).to eq(1) |
| 530 | + expect(topics).not_to include(other_topic2) |
| 531 | + expect(topics).to include(other_topic) |
| 532 | + end |
531 | 533 | end
|
532 | 534 | end
|
533 | 535 | end
|
| 536 | + |
| 537 | + describe "#unaccept_answer!" do |
| 538 | + it "works even when the topic has been deleted" do |
| 539 | + user = Fabricate(:user, trust_level: 1) |
| 540 | + topic = Fabricate(:topic, user:) |
| 541 | + reply = Fabricate(:post, topic:, user:, post_number: 2) |
| 542 | + |
| 543 | + DiscourseSolved.accept_answer!(reply, user) |
| 544 | + |
| 545 | + topic.trash!(Discourse.system_user) |
| 546 | + reply.reload |
| 547 | + |
| 548 | + expect(reply.topic).to eq(nil) |
| 549 | + |
| 550 | + expect { DiscourseSolved.unaccept_answer!(reply) }.not_to raise_error |
| 551 | + end |
| 552 | + end |
534 | 553 | end
|
0 commit comments