mirror of
https://github.com/chenasraf/snpr.git
synced 2026-05-18 01:39:01 +00:00
* Passwords now need to be 8 characters long (new default in authlogic). * To login to the Sidekiq web interface, log in to opensnp.org, if you have the `admin` flag set, you will find it at the usual place. * I finally found out why Rubocop didn't complain about the frozen string literal pragma missing and added all of them. * Rubocop complained about keyword arguments, which is only relevant for Rails 5, so I disabled the cop. * I removed the `inherit_from: .rubocop_todo.yml` from `.rubocop.yml`, so Hound does complain about **all** the issues. I also added a few tasks for running Rubocop.
38 lines
1.1 KiB
Ruby
38 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
RSpec.describe 'upsert_user_snps' do
|
|
let(:genotype) { create(:genotype) }
|
|
let(:snp) { create(:snp, name: 'rs1') }
|
|
let!(:existing_user_snp) { create(:user_snp, genotype: genotype, snp: snp, local_genotype: 'AG') }
|
|
let(:temp_table_name) { "user_snps_temp_#{genotype.id}" }
|
|
|
|
before do
|
|
ActiveRecord::Base.connection.execute(<<-SQL)
|
|
CREATE TEMPORARY TABLE #{temp_table_name} (
|
|
snp_name varchar(32),
|
|
chromosome varchar(32),
|
|
position varchar(32),
|
|
local_genotype char(2)
|
|
) ON COMMIT DROP;
|
|
|
|
INSERT INTO #{temp_table_name} (snp_name, local_genotype)
|
|
VALUES ('rs1', 'AA'), ('rs2', 'AC');
|
|
SQL
|
|
|
|
ActiveRecord::Base.connection.execute("SELECT upsert_user_snps(#{genotype.id})")
|
|
end
|
|
|
|
it 'inserts a new user-SNP' do
|
|
expect(UserSnp.find_by(snp_name: 'rs1')).to have_attributes(
|
|
'genotype_id' => genotype.id,
|
|
'local_genotype' => 'AA'
|
|
)
|
|
end
|
|
|
|
it 'updates existing user-SNP' do
|
|
expect(UserSnp.find_by(snp_name: 'rs2')).to have_attributes(
|
|
'genotype_id' => genotype.id,
|
|
'local_genotype' => 'AC'
|
|
)
|
|
end
|
|
end
|