Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Updated to the latest version of clj-record. Created an initial trust…
… score table and model.
- Loading branch information
1 parent
600a97f
commit 1629482
Showing
6 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ db | |
classes | ||
logs | ||
private_key.dat | ||
.lein-failures | ||
pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(ns darkexchange.model.trust-score | ||
(:require [clj-record.boot :as clj-record-boot] | ||
[darkexchange.model.identity :as identity]) | ||
(:use darkexchange.model.base)) | ||
|
||
(clj-record.core/init-model | ||
(:associations (belongs-to scorer :fk scorer_id :model identity) | ||
(belongs-to target :fk target_id :model identity))) | ||
|
||
(defn add-trust-score [target-identity basic-score] | ||
(insert { :scorer_id (:id (identity/current-user-identity)) :target_id (:id target-identity) :basic basic-score })) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(ns test.darkexchange.model.trust-score | ||
(:require [test.init :as test-init] | ||
[darkexchange.model.identity :as identity-model] | ||
[test.fixtures.identity :as identity-fixture] | ||
[test.fixtures.util :as fixtures-util]) | ||
(:use clojure.contrib.test-is | ||
darkexchange.model.trust-score)) | ||
|
||
(fixtures-util/use-fixture-maps :once identity-fixture/fixture-map) | ||
|
||
(deftest test-add-trust-score | ||
(let [basic-trust-score 0.5 | ||
target-identity (identity-model/get-record 1) | ||
trust-score-id (add-trust-score target-identity basic-trust-score) | ||
trust-score (when trust-score-id (get-record trust-score-id))] | ||
(is trust-score-id) | ||
(is (= basic-trust-score (:basic trust-score))) | ||
(is (= (:id (identity-model/current-user-identity)) (:scorer_id trust-score))) | ||
(is (= (:id target-identity) (:target_id trust-score))) | ||
(destroy-record trust-score))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters