forked from openSNP/snpr
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openSNP#20 from tsujigiri/known_phenotypes
Known phenotypes
- Loading branch information
Showing
9 changed files
with
51 additions
and
44 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 |
---|---|---|
|
@@ -20,3 +20,4 @@ vendor/bundle | |
public/data | ||
coverage* | ||
hiredis/ | ||
log/ |
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
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
class UserPhenotype < ActiveRecord::Base | ||
belongs_to :phenotype, dependent: :destroy | ||
belongs_to :user | ||
validates_presence_of :variation | ||
belongs_to :phenotype, dependent: :destroy | ||
belongs_to :user | ||
validates_presence_of :variation | ||
|
||
attr_accessible :variation,:phenotype_id,:js_modal | ||
attr_accessible :variation,:phenotype_id,:js_modal | ||
|
||
searchable do | ||
text :variation | ||
end | ||
searchable do | ||
text :variation | ||
integer :phenotype_id | ||
end | ||
end |
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,25 @@ | ||
require_relative '../test_helper' | ||
|
||
class UserPhenotypeTest < ActiveSupport::TestCase | ||
context "UserPhenotype" do | ||
setup do | ||
@phenotype = Factory :phenotype | ||
@user_phenotype_0 = Factory :user_phenotype, | ||
phenotype_id: @phenotype.id, variation: 'male' | ||
@user_phenotype_1 = Factory :user_phenotype, | ||
phenotype_id: @phenotype.id, variation: 'female' | ||
@user_phenotype_2 = Factory :user_phenotype, | ||
phenotype_id: @phenotype.id + 1, variation: 'male' | ||
Sunspot.commit | ||
end | ||
|
||
should "find similar user phenotypes" do | ||
phenotype = @phenotype | ||
results = UserPhenotype.search do | ||
with(:phenotype_id, phenotype.id) | ||
fulltext 'male' | ||
end.results | ||
assert_equal [@user_phenotype_0], results.sort_by(&:id) | ||
end | ||
end | ||
end |