File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ class AnswerAnalysisJob < ApplicationJob
2+ def perform ( answer_id )
3+ AnswerAnalysis ::TagTopicsJob . perform_later ( answer_id )
4+ AnswerAnalysis ::AnswerRelevancyJob . perform_later ( answer_id )
5+ end
6+ end
Original file line number Diff line number Diff line change @@ -15,10 +15,8 @@ def perform(question_id)
1515 end
1616
1717 if answer . persisted?
18- # TODO: Once we've added a few metrics we should move these to a single job that
19- # kicks off all analysis jobs.
20- AnswerAnalysis ::TagTopicsJob . perform_later ( answer . id )
21- AnswerAnalysis ::AnswerRelevancyJob . perform_later ( answer . id )
18+ AnswerAnalysisJob . perform_later ( answer . id )
19+
2220 end
2321 end
2422end
Original file line number Diff line number Diff line change 1+ RSpec . describe AnswerAnalysisJob do
2+ let ( :answer ) { build :answer }
3+
4+ before do
5+ allow ( AnswerAnalysis ::TagTopicsJob ) . to receive ( :perform_later )
6+ allow ( AnswerAnalysis ::AnswerRelevancyJob ) . to receive ( :perform_later )
7+ end
8+
9+ it "calls the AnswerAnalysis::TagTopicsJob with the answer id" do
10+ described_class . new . perform ( answer . id )
11+ expect ( AnswerAnalysis ::TagTopicsJob ) . to have_received ( :perform_later ) . with ( answer . id )
12+ end
13+
14+ it "calls the AnswerAnalysis::AnswerRelevancyJob with the answer id" do
15+ described_class . new . perform ( answer . id )
16+ expect ( AnswerAnalysis ::AnswerRelevancyJob ) . to have_received ( :perform_later ) . with ( answer . id )
17+ end
18+ end
Original file line number Diff line number Diff line change 55
66 before do
77 allow ( AnswerComposition ::Composer ) . to receive ( :call ) . and_return ( returned_answer )
8- allow ( AnswerAnalysis ::TagTopicsJob ) . to receive ( :perform_later )
9- allow ( AnswerAnalysis ::AnswerRelevancyJob ) . to receive ( :perform_later )
8+ allow ( AnswerAnalysisJob ) . to receive ( :perform_later )
109 end
1110
1211 it_behaves_like "a job in queue" , "answer"
1817 . and change ( AnswerSource , :count ) . by ( 2 )
1918 end
2019
21- it "calls the AnswerAnalysis::TagTopicsJob with the answer_id " do
20+ it "calls the AnswerAnalysisJob with the answer id " do
2221 described_class . new . perform ( question . id )
23- expect ( AnswerAnalysis ::TagTopicsJob ) . to have_received ( :perform_later ) . with ( returned_answer . id )
24- end
25-
26- it "calls the AnswerAnalysis::AnswerRelevancyJob with the answer_id" do
27- described_class . new . perform ( question . id )
28- expect ( AnswerAnalysis ::AnswerRelevancyJob ) . to have_received ( :perform_later ) . with ( returned_answer . id )
22+ expect ( AnswerAnalysisJob ) . to have_received ( :perform_later ) . with ( returned_answer . id )
2923 end
3024
3125 context "when the question has already been answered" do
You can’t perform that action at this time.
0 commit comments