Rename local_genotype to snp_variation SnpediaPaper

This commit is contained in:
Helge Rausch
2015-07-08 08:39:53 +02:00
parent e6ac9c5210
commit 4126d3afb7
5 changed files with 9 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
module SnpediaPapersHelper
def bold_if_matching_local_genotype(snpedia_paper, user_snp, &block)
def bold_if_matching_variation(snpedia_paper, user_snp, &block)
if snpedia_paper && user_snp &&
snpedia_paper.local_genotype == user_snp.local_genotype.split('').sort.join
snpedia_paper.snp_variation == user_snp.local_genotype.split('').sort.join
content_tag('b', &block)
else

View File

@@ -10,7 +10,7 @@ class SnpediaPaper < ActiveRecord::Base
read_attribute(:summary).presence || "No summary provided."
end
def local_genotype
def snp_variation
url =~ /\((.*);(.*)\)$/
"#{$1}#{$2}"
end

View File

@@ -9,8 +9,8 @@
<% snp.snpedia_papers.each do |p| %>
<tr>
<td>
<%= bold_if_matching_local_genotype(p, user_snp) do %>
<%= link_to "#{snp.name} #{p.local_genotype.split('').join('/')}", p.url %>
<%= bold_if_matching_variation(p, user_snp) do %>
<%= link_to "#{snp.name} #{p.snp_variation.split('').join('/')}", p.url %>
<% end %>
</td>
<td><b><%= p.summary.capitalize %></b></td>

View File

@@ -3,9 +3,9 @@ RSpec.describe SnpediaPaper do
build(:snpedia_paper, url: 'http://www.snpedia.com/index.php/Rs1234(A;C)')
end
describe '#local_genotype' do
it 'extracts the local genotype from the url' do
expect(subject.local_genotype).to eq('AC')
describe '#snp_variation' do
it 'extracts the SNP variation from the url' do
expect(subject.snp_variation).to eq('AC')
end
end
end

View File

@@ -2,7 +2,7 @@ RSpec.describe 'snps/_snpedia_papers.html.erb' do
let(:snpedia_paper) do
double(:snpedia_paper, url: 'http://www.snpedia.com/index.php/Rs1234(A;C)',
summary: 'Green hair',
local_genotype: 'AC')
snp_variation: 'AC')
end
let(:snp) { double('snp', name: 'rs1234', snpedia_papers: [snpedia_paper]) }