diff --git a/spec/models/machine_learning_spec.rb b/spec/models/machine_learning_spec.rb index 891a8600c68..2ae37871c32 100644 --- a/spec/models/machine_learning_spec.rb +++ b/spec/models/machine_learning_spec.rb @@ -327,56 +327,56 @@ def full_sanitizer(string) end end - # describe "#export_budget_investments_to_json" do - # it "creates a JSON file with all budget investments" do - # first_budget_investment = create(:budget_investment) - # last_budget_investment = create(:budget_investment) - # - # machine_learning = MachineLearning.new(job) - # machine_learning.send(:export_budget_investments_to_json) - # - # json_file = MachineLearning.data_folder.join("budget_investments.json") - # json = JSON.parse(File.read(json_file)) - # - # expect(json).to be_an Array - # expect(json.size).to be 2 - # - # expect(json.first["id"]).to eq first_budget_investment.id - # expect(json.first["title"]).to eq first_budget_investment.title - # expect(json.first["description"]).to eq full_sanitizer(first_budget_investment.description) - # - # expect(json.last["id"]).to eq last_budget_investment.id - # expect(json.last["title"]).to eq last_budget_investment.title - # expect(json.last["description"]).to eq full_sanitizer(last_budget_investment.description) - # end - # end - # - # describe "#export_comments_to_json" do - # it "creates a JSON file with all comments" do - # first_comment = create(:comment) - # last_comment = create(:comment) - # - # machine_learning = MachineLearning.new(job) - # machine_learning.send(:export_comments_to_json) - # - # json_file = MachineLearning.data_folder.join("comments.json") - # json = JSON.parse(File.read(json_file)) - # - # expect(json).to be_an Array - # expect(json.size).to be 2 - # - # expect(json.first["id"]).to eq first_comment.id - # expect(json.first["commentable_id"]).to eq first_comment.commentable_id - # expect(json.first["commentable_type"]).to eq first_comment.commentable_type - # expect(json.first["body"]).to eq full_sanitizer(first_comment.body) - # - # expect(json.last["id"]).to eq last_comment.id - # expect(json.last["commentable_id"]).to eq last_comment.commentable_id - # expect(json.last["commentable_type"]).to eq last_comment.commentable_type - # expect(json.last["body"]).to eq full_sanitizer(last_comment.body) - # end - # end - # + describe "#export_budget_investments_to_json" do + it "creates a JSON file with all budget investments" do + first_budget_investment = create(:budget_investment) + last_budget_investment = create(:budget_investment) + + machine_learning = MachineLearning.new(job) + machine_learning.send(:export_budget_investments_to_json) + + json_file = MachineLearning.data_folder.join("budget_investments.json") + json = JSON.parse(File.read(json_file)) + + expect(json).to be_an Array + expect(json.size).to be 2 + + expect(json.first["id"]).to eq first_budget_investment.id + expect(json.first["title"]).to eq first_budget_investment.title + expect(json.first["description"]).to eq full_sanitizer(first_budget_investment.description) + + expect(json.last["id"]).to eq last_budget_investment.id + expect(json.last["title"]).to eq last_budget_investment.title + expect(json.last["description"]).to eq full_sanitizer(last_budget_investment.description) + end + end + + describe "#export_comments_to_json" do + it "creates a JSON file with all comments" do + first_comment = create(:comment) + last_comment = create(:comment) + + machine_learning = MachineLearning.new(job) + machine_learning.send(:export_comments_to_json) + + json_file = MachineLearning.data_folder.join("comments.json") + json = JSON.parse(File.read(json_file)) + + expect(json).to be_an Array + expect(json.size).to be 2 + + expect(json.first["id"]).to eq first_comment.id + expect(json.first["commentable_id"]).to eq first_comment.commentable_id + expect(json.first["commentable_type"]).to eq first_comment.commentable_type + expect(json.first["body"]).to eq full_sanitizer(first_comment.body) + + expect(json.last["id"]).to eq last_comment.id + expect(json.last["commentable_id"]).to eq last_comment.commentable_id + expect(json.last["commentable_type"]).to eq last_comment.commentable_type + expect(json.last["body"]).to eq full_sanitizer(last_comment.body) + end + end + # describe "#run_machine_learning_scripts" do # it "returns true if python script executed correctly" do # machine_learning = MachineLearning.new(job)