Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tsujigiri committed Mar 15, 2015
1 parent 533b691 commit 535ac82
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 168 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--color
--require spec_helper
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ gem "sass"
#end

group :test do
gem 'test-unit' # TODO: Remove me
gem 'minitest' # TODO: Remove me
gem 'rspec-rails'
gem 'shoulda-context', require: false
gem 'factory_girl_rails'
gem 'mocha', require: false
Expand All @@ -76,7 +79,6 @@ end

group :development, :test do
gem 'uuidtools'
gem 'rspec-rails'
gem 'pry-rails', require: 'pry' unless ENV['CI']
end

Expand All @@ -85,5 +87,5 @@ group :development do
gem 'spring'
gem 'spring-commands-rspec'
gem 'capistrano', '~> 2.0'
gem 'rvm-capistrano', '1.4.4'
gem 'rvm-capistrano', '1.4.4', require: false
end
44 changes: 29 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ GEM
builder
multi_json
arel (4.0.2)
authlogic (3.3.0)
authlogic (3.4.5)
activerecord (>= 3.2)
activesupport (>= 3.2)
request_store (~> 1.0)
scrypt (~> 1.2)
bcrypt-ruby (3.1.2)
builder (3.1.4)
capistrano (2.15.5)
Expand All @@ -72,7 +74,7 @@ GEM
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
capybara (2.3.0)
capybara (2.4.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
Expand Down Expand Up @@ -102,6 +104,9 @@ GEM
factory_girl (~> 4.4.0)
railties (>= 3.0.0)
ffi (1.9.3)
ffi-compiler (0.1.3)
ffi (>= 1.0.0)
rake
fitgem (0.10.0)
oauth
formatador (0.2.5)
Expand Down Expand Up @@ -143,7 +148,7 @@ GEM
metaclass (0.0.1)
method_source (0.8.2)
mime-types (2.4.3)
mini_portile (0.6.0)
mini_portile (0.6.2)
minitest (4.7.5)
mocha (0.14.0)
metaclass (~> 0.0.1)
Expand All @@ -157,8 +162,8 @@ GEM
net-ssh (>= 2.6.5)
netrc (0.7.7)
newrelic_rpm (3.6.8.168)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oauth (0.4.7)
paperclip (4.1.1)
activemodel (>= 3.0.0)
Expand All @@ -173,11 +178,12 @@ GEM
plos (0.0.7)
nokogiri
rest-client
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
power_assert (0.2.3)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-rails (0.3.2)
pry-rails (0.3.3)
pry (>= 0.9.10)
rack (1.5.2)
rack-protection (1.5.1)
Expand Down Expand Up @@ -208,35 +214,39 @@ GEM
redis-namespace (1.3.1)
redis (~> 3.0.0)
ref (1.0.5)
request_store (1.1.0)
rest-client (1.7.2)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-core (3.0.0)
rspec-core (3.0.4)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.0)
rspec-expectations (3.0.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.1)
rspec-mocks (3.0.4)
rspec-support (~> 3.0.0)
rspec-rails (3.0.1)
rspec-rails (3.0.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-support (~> 3.0.0)
rspec-support (3.0.0)
rspec-support (3.0.4)
rvm-capistrano (1.4.4)
capistrano (>= 2.15.4)
safe_yaml (0.9.7)
sanitize (2.0.6)
nokogiri (>= 1.4.4)
sass (3.2.12)
scrypt (1.2.1)
ffi-compiler (>= 0.0.2)
rake
shoulda-context (1.1.5)
sidekiq (2.16.0)
celluloid (>= 0.15.2)
Expand All @@ -257,7 +267,7 @@ GEM
slim (1.3.9)
temple (~> 0.6.3)
tilt (~> 1.3, >= 1.3.3)
slop (3.5.0)
slop (3.6.0)
spring (1.1.3)
spring-commands-rspec (1.0.2)
spring (>= 0.9.1)
Expand All @@ -271,6 +281,8 @@ GEM
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
temple (0.6.7)
test-unit (3.0.9)
power_assert
therubyracer (0.12.0)
libv8 (~> 3.16.14.0)
ref
Expand Down Expand Up @@ -328,6 +340,7 @@ DEPENDENCIES
lograge
mediawiki-gateway
mendeley!
minitest
mocha
nested_form!
newrelic_rpm
Expand All @@ -353,6 +366,7 @@ DEPENDENCIES
slim (~> 1.3.8)
spring
spring-commands-rspec
test-unit
therubyracer
twitter-bootstrap-rails
uglifier
Expand Down
14 changes: 9 additions & 5 deletions app/controllers/phenotypes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def new

def create
unless @phenotype = Phenotype.find_by_characteristic(params[:phenotype][:characteristic])
@phenotype = Phenotype.create(params[:phenotype])
@phenotype = Phenotype.create(phenotype_params)

# award: created one (or more) phenotypes
current_user.update_attributes(:phenotype_creation_counter => (current_user.phenotype_creation_counter + 1) )
Expand All @@ -45,14 +45,14 @@ def create
check_and_award_new_phenotypes(10, "Created 10 new phenotypes")
end

if params[:phenotype][:characteristic] == ""
if params[:phenotype][:characteristic].blank?
flash[:warning] = "Phenotype characteristic may not be empty"
redirect_to :action => "new"
else

@phenotype.save
@phenotype = Phenotype.find_by_characteristic(params[:phenotype][:characteristic])
Sidekiq::Client.enqueue(Mailnewphenotype, @phenotype.id,current_user.id)
@phenotype = Phenotype.find_by(characteristic: params[:phenotype][:characteristic])
Sidekiq::Client.enqueue(Mailnewphenotype, @phenotype.id, current_user.id)

if UserPhenotype.find_by_phenotype_id_and_user_id(@phenotype.id,current_user.id).nil?

Expand Down Expand Up @@ -182,7 +182,7 @@ def feed

def get_genotypes
Sidekiq::Client.enqueue(Zipgenotypingfiles, params[:id],
params[:variation], current_user.email)
params[:variation], current_user.email)
@phenotype = Phenotype.find(params[:id])
@variation = params[:variation]
respond_to do |format|
Expand Down Expand Up @@ -301,4 +301,8 @@ def check_and_award_additional_phenotypes(amount, achievement_string)
flash[:achievement] = %(Congratulations! You've unlocked an achievement: <a href="#{url_for(@achievement)}">#{@achievement.award}</a>).html_safe
end
end

def phenotype_params
params.require(:phenotype).permit(:description, :characteristic)
end
end
3 changes: 2 additions & 1 deletion app/controllers/snps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ def json_element(params)
end

def find_snp
@snp = Snp.find(params[:id].downcase) || not_found
@snp = Snp.friendly.find(params[:id].downcase)
@snp ||= Snp.find(params[:id])

# If an old id or a numeric id was used to find the record, then
# the request path will not match the post_path, and we should do
Expand Down
3 changes: 2 additions & 1 deletion app/models/snp_reference.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class SnpReference < ActiveRecord::Base
self.primary_keys = :snp_id, :paper_id, :paper_type
belongs_to :snp
belongs_to :paper, polymorphic: true
validates_presence_of :snp, :paper
#validates_presence_of :snp, :paper
end
30 changes: 15 additions & 15 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ class User < ActiveRecord::Base
has_attached_file :avatar,
styles: { medium: "300x300>", thumb: "100x100>#", head: "32x32#" },
default_url: 'standard_:style.png'

before_validation :clear_avatar

validates_attachment_size :avatar, less_than: 1.megabyte
validates_attachment_content_type :avatar,
content_type: ['image/jpeg', 'image/png', 'image/gif']
# call on authlogic
acts_as_authentic do |c|
# replace SHA512 by bcrypt
c.transition_from_crypto_providers = Authlogic::CryptoProviders::Sha512
c.crypto_provider = Authlogic::CryptoProviders::BCrypt
# replace SHA512 by bcrypt
c.transition_from_crypto_providers = Authlogic::CryptoProviders::Sha512
c.crypto_provider = Authlogic::CryptoProviders::BCrypt
end
#after_create :make_standard_phenotypes

Expand Down Expand Up @@ -47,17 +47,17 @@ def deliver_password_reset_instructions!
end

def phenotype_length
# tiny workaround for user-index
phenotypes.length
# tiny workaround for user-index
phenotypes.length
end

def user_has_sequence_string
# used in the user-index-page instead of ugly true/false
if has_sequence
"Yes"
else
"No"
end
# used in the user-index-page instead of ugly true/false
if has_sequence
"Yes"
else
"No"
end
end

def check_if_phenotype_exists(charact)
Expand All @@ -80,7 +80,7 @@ def check_and_make_standard_phenotypes(charact)
UserPhenotype.create(phenotype_id: @phen_id, variation: '', user_id: id)
end
end

def make_standard_phenotypes
check_and_make_standard_phenotypes('Hair color')
check_and_make_standard_phenotypes('Eye color')
Expand All @@ -96,7 +96,7 @@ def delete_avatar
!!@delete_avatar
end
alias_method :delete_avatar?, :delete_avatar

def clear_avatar
self.avatar = nil if delete_avatar?
end
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion config/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
9 changes: 3 additions & 6 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
Expand All @@ -23,9 +20,6 @@
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict

# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.1
Expand All @@ -35,5 +29,8 @@

# Expands the lines which load the assets
config.assets.debug = true

# Do not eager load code on boot.
config.eager_load = false
end

3 changes: 3 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,7 @@
config.assets.digest = true

config.lograge.enabled = true

# Eager load code on boot.
config.eager_load = true
end
3 changes: 3 additions & 0 deletions config/environments/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@

# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify

# Eager load code on boot.
config.eager_load = true
end
9 changes: 3 additions & 6 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
Expand All @@ -33,13 +30,13 @@
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict

# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"

# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
config.assets.allow_debugging = true

# Do not eager load code on boot.
config.eager_load = false
end
4 changes: 0 additions & 4 deletions config/initializers/0_load_app_config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
raw_config = File.read("#{Rails.root}/config/app_config.yml")
APP_CONFIG = YAML.load(raw_config)[Rails.env].symbolize_keys


Rails.logger.instance_variable_get(:@logger).instance_variable_get(:@log_dest).sync = true if Rails.logger

Loading

0 comments on commit 535ac82

Please sign in to comment.