Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Known phenotypes #20

Merged
merged 11 commits into from

2 participants

Commits on Mar 30, 2012
  1. @tsujigiri
  2. @tsujigiri
  3. @tsujigiri
  4. @tsujigiri

    starting solr before tests

    tsujigiri authored
  5. @tsujigiri

    dirty hack

    tsujigiri authored
  6. @tsujigiri

    better?

    tsujigiri authored
  7. @tsujigiri

    poking around

    tsujigiri authored
  8. @tsujigiri

    what are we dealing with?

    tsujigiri authored
  9. @tsujigiri

    another try

    tsujigiri authored
  10. @tsujigiri

    foo

    tsujigiri authored
Commits on Mar 31, 2012
  1. @tsujigiri

    changing a test a bit

    tsujigiri authored
This page is out of date. Refresh to see the latest.
View
1  .gitignore
@@ -20,3 +20,4 @@ vendor/bundle
public/data
coverage*
hiredis/
+log/
View
1  .travis.yml
@@ -4,6 +4,7 @@ env: DB=postgres
before_install:
- git clone https://github.com/antirez/hiredis.git && cd hiredis && make && sudo make install && sudo ldconfig && cd ..
before_script:
+ - bash -c "find /home/vagrant/.rvm/gems -name sunspot_test.rb -exec sed -i 's/at_exit/#at_exit/' {} \;"
- cp config/database.yml.ci config/database.yml
- echo "foo" > mail_username.txt
- echo "bar" > mail_password.txt
View
1  Gemfile
@@ -47,6 +47,7 @@ group :test do
gem 'factory_girl'
gem 'mocha'
gem 'ruby-debug19'
+ gem 'sunspot_test'
end
# gem 'email_veracity' # to check whether user-mails are OK
View
40 Gemfile.ci
@@ -32,38 +32,8 @@ gem 'paperclip', '~> 2.4'
gem 'friendly_id', :git => 'https://github.com/norman/friendly_id.git'
gem 'recommendify', :git => 'https://github.com/paulasmuth/recommendify.git'
-#group :production do
-# gem 'rpm_contrib'
-# gem 'newrelic_rpm'
-#end
-
-group :test do
- gem 'shoulda-context'
- gem 'shoulda-matchers'
- gem 'factory_girl'
- gem 'mocha'
- gem 'ruby-debug19'
-end
-
-
-# gem 'email_veracity' # to check whether user-mails are OK
-# authlogic does that anyway
-
-# Use unicorn as the web server
-# gem 'unicorn'
-
-# Deploy with Capistrano
-# gem 'capistrano'
-
-# Bundle the extra gems:
-# gem 'bj'
-# gem 'nokogiri'
-# gem 'sqlite3-ruby', :require => 'sqlite3'
-# gem 'aws-s3', :require => 'aws/s3'
-
-# Bundle gems for the local environment. Make sure to
-# put test-only gems in this group so their generators
-# and rake tasks are available in development mode:
-# group :development, :test do
-# gem 'webrat'
-# end
+gem 'shoulda-context'
+gem 'shoulda-matchers'
+gem 'factory_girl'
+gem 'mocha'
+gem 'sunspot_test'
View
3  Gemfile.lock
@@ -157,6 +157,8 @@ GEM
sunspot_rails (1.2.1)
nokogiri
sunspot (= 1.2.1)
+ sunspot_test (0.4.0)
+ sunspot_rails (>= 1.2.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -194,4 +196,5 @@ DEPENDENCIES
shoulda-context
shoulda-matchers
sunspot_rails (~> 1.2.1)
+ sunspot_test
will_paginate (= 3.0.pre2)
View
7 app/jobs/zipgenotypingfiles.rb
@@ -3,8 +3,11 @@
class Zipgenotypingfiles
@queue = :zipgenotyping
- def self.perform(phenotype_id,variation,target_address)
- @user_phenotypes = UserPhenotype.find_all_by_phenotype_id_and_variation(phenotype_id,variation)
+ def self.perform(phenotype_id, variation, target_address)
+ @user_phenotypes = UserPhenotype.search do
+ with :phenotype_id, phenotype_id
+ fulltext variation
+ end.results
@genotyping_files = []
@user_phenotypes.each do |up|
@user = User.find_by_id(up.user_id)
View
15 app/models/user_phenotype.rb
@@ -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
View
2  test/test_helper.rb
@@ -2,6 +2,8 @@
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "authlogic/test_case"
+SunspotTest.solr_startup_timeout = 30
+require 'sunspot_test/test_unit'
class ActiveSupport::TestCase
FactoryGirl.find_definitions
View
25 test/unit/user_phenotype_test.rb
@@ -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
Something went wrong with that request. Please try again.