|
| 1 | +defmodule CodeCorps.UserTaskMatcherTest do |
| 2 | + use CodeCorps.ModelCase |
| 3 | + |
| 4 | + import CodeCorps.UserTaskMatcher |
| 5 | + |
| 6 | + test "can find top x tasks for a user's skill" do |
| 7 | + coding = insert(:skill, title: "coding") |
| 8 | + design = insert(:skill, title: "design") |
| 9 | + |
| 10 | + account_page = insert(:task) |
| 11 | + settings_page = insert(:task) |
| 12 | + photoshop = insert(:task) |
| 13 | + |
| 14 | + insert(:task) |
| 15 | + |
| 16 | + insert(:task_skill, task: account_page, skill: design) |
| 17 | + insert(:task_skill, task: account_page, skill: coding) |
| 18 | + insert(:task_skill, task: settings_page, skill: design) |
| 19 | + insert(:task_skill, task: settings_page, skill: coding) |
| 20 | + insert(:task_skill, task: photoshop, skill: coding) |
| 21 | + |
| 22 | + user = insert(:user) |
| 23 | + |
| 24 | + insert(:user_skill, user: user, skill: design) |
| 25 | + insert(:user_skill, user: user, skill: coding) |
| 26 | + |
| 27 | + tasks = match_user(user, 2) |
| 28 | + |
| 29 | + assert(length(tasks) == 2) |
| 30 | + assert(length(match_user(user, 3)) == 3) |
| 31 | + end |
| 32 | +end |
0 commit comments