Add test for not-yet-entered variations

This commit is contained in:
Helge Rausch
2016-07-24 12:00:26 +02:00
parent e9b3d18f43
commit 5425422c3e
7 changed files with 45 additions and 3 deletions

View File

@@ -70,6 +70,7 @@ group :test do
gem 'webmock'
gem 'vcr'
gem 'capybara'
gem 'poltergeist'
gem 'database_cleaner'
gem 'timecop'
gem 'codeclimate-test-reporter', require: false
@@ -79,6 +80,7 @@ group :development, :test do
gem 'uuidtools'
gem 'pry-rails', require: 'pry' unless ENV['CI']
gem 'factory_girl_rails'
gem 'launchy'
end
group :development do

View File

@@ -92,6 +92,7 @@ GEM
chronic (0.10.2)
climate_control (0.0.3)
activesupport (>= 3.0)
cliver (0.3.2)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
codeclimate-test-reporter (0.6.0)
@@ -159,6 +160,8 @@ GEM
jquery-ui-rails (5.0.5)
railties (>= 3.2.16)
json (1.8.3)
launchy (2.4.3)
addressable (~> 2.3)
less (2.6.0)
commonjs (~> 0.2.7)
less-rails (2.7.1)
@@ -224,6 +227,10 @@ GEM
plos (0.0.7)
nokogiri
rest-client
poltergeist (1.10.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
power_assert (0.3.0)
powerpack (0.1.1)
pry (0.10.3)
@@ -384,6 +391,9 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.6.4)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
whenever (0.9.4)
chronic (>= 0.6.3)
will_paginate (3.1.0)
@@ -415,6 +425,7 @@ DEPENDENCIES
jquery-rails
jquery-ui-rails
json
launchy
lograge
mediawiki-gateway
mendeley!
@@ -425,6 +436,7 @@ DEPENDENCIES
pg
pg_search
plos
poltergeist
pry-rails
rails (~> 4.2.0)
rails3-generators

View File

@@ -1,5 +1,5 @@
class PhenotypesController < ApplicationController
before_filter :require_user, only: [ :new, :create, :get_genotypes,:recommend_phenotype ]
before_filter :require_user, only: %i(new create get_genotypes recommend_phenotype)
helper_method :sort_column, :sort_direction
def index

View File

@@ -0,0 +1,21 @@
RSpec.feature 'Not-yet-entered variations list', :js do
let!(:user) { create(:user) }
let!(:phenotype1) { create(:phenotype, characteristic: 'Eye count') }
let!(:phenotype2) { create(:phenotype, characteristic: 'tentacle count') }
let!(:phenotype3) { create(:phenotype, characteristic: 'Beard Color') }
before do
sign_in(user)
end
scenario 'a user enters a variation from the list' do
expect(page.current_path).to eq("/users/#{user.id}")
expect(page).to have_content('Variations you did not enter yet (3)')
expect(page).to have_content('Eye count')
find("[href=\"#new_user_phenotype_modal#{phenotype1.id}\"]").click
fill_in('user_phenotype[variation]', with: '1000')
click_on('Save')
expect(page).to have_content('Variations you did not enter yet (2)')
expect(UserPhenotype.find_by(user: user, phenotype: phenotype1).variation).to eq('1000')
end
end

View File

@@ -9,6 +9,8 @@ require 'sidekiq/testing'
require 'factory_girl_rails'
require 'pry-rails' unless ENV['CI']
require 'authlogic/test_case'
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
@@ -53,10 +55,13 @@ RSpec.configure do |config|
DatabaseCleaner.strategy = :transaction
end
config.before(:example, truncate: true) do
truncate = proc do
DatabaseCleaner.strategy = :truncation, { except: %w(achievements) }
end
config.before(:example, truncate: true, &truncate)
config.before(:example, js: true, &truncate)
config.before(:example) do
DatabaseCleaner.start
end

View File

@@ -9,6 +9,8 @@ module Authlogic
def sign_in(user)
visit '/signin'
expect(page).to have_content('Login')
fill_in('Email', with: user.email)
fill_in('Password', with: 'jeheim')

View File

@@ -2,5 +2,5 @@ VCR.configure do |c|
c.cassette_library_dir = 'spec/vcr'
c.hook_into :webmock
c.configure_rspec_metadata!
c.ignore_hosts 'codeclimate.com'
c.ignore_hosts %w(127.0.0.1 codeclimate.com)
end