-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #330 from philippbayer/snp_update_feed
Snp update feed
- Loading branch information
Showing
4 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class LastUpdatedSnpsService | ||
def self.get_last_thirty_updated_snps(user) | ||
[SnpediaPaper, MendeleyPaper, GenomeGovPaper, PlosPaper].flat_map do |papers| | ||
papers.last(30).select do |paper| | ||
paper.snps.any? { |s| s.users.exists?(user.id) } | ||
end | ||
end.sort_by(&:updated_at).reverse.take(30) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
RSpec.describe 'Arriving as user' do | ||
let(:snp) { double('snp', name: 'rs1234', snpedia_papers: [snpedia_paper]) } | ||
let!(:user) { create(:user, name: 'Potato Bill', snps: [snp]) } | ||
|
||
let(:snpedia_paper) do | ||
double(:snpedia_paper, url: 'http://www.snpedia.com/index.php/Rs1234(A;C)', | ||
summary: 'Green hair', | ||
snp_variation: 'AC', | ||
created_at: '1969-07-20 20:17:40', | ||
id: 1) | ||
end | ||
|
||
context 'as a signed-in user' do | ||
before do | ||
sign_in(user) | ||
end | ||
|
||
scenario 'the user arrives on landing page' do | ||
visit root_path | ||
|
||
expect(page).to have_content('Hello Potato!') | ||
expect(page).to have_content('rs1234') | ||
|
||
# Test Your last 30 updated SNPs feed | ||
expect(page).to have_content('Received new data from SNPedia') | ||
end | ||
end | ||
end |