New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tests #388
Added tests #388
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
RSpec.describe 'Arriving at openSNP' do | ||
let!(:user) { create(:user, name: 'Potato Bill', email: 'potato@example.com')} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing inside }. |
||
let!(:phenotype) {create(:phenotype, characteristic: 'Eye color')} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing inside {. |
||
|
||
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('Eye color') | ||
end | ||
end | ||
|
||
context 'as a signed-out user' do | ||
scenario 'user arrives on main page' do | ||
visit root_path | ||
expect(page).to have_content('Sign up') | ||
expect(page).to have_content('Download data') | ||
expect(page).to have_content('Sign In') | ||
end | ||
scenario 'user forgot their password' do | ||
visit root_path | ||
click_on('Sign In') | ||
click_on('Forgot password?') | ||
fill_in('Email', with: 'potato@example.com') | ||
click_on('Reset my password') | ||
expect(page).to have_content('Instructions to reset your password') | ||
mail = ActionMailer::Base.deliveries.last | ||
expect(mail.subject).to include('openSNP.org Password Reset Instructions') | ||
mail.parts.each do |p| | ||
expect(p.body.raw_source).to include(user.name) | ||
expect(p.body.raw_source).to include('password_resets') | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
require 'spec_helper' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an empty line after magic comments. |
||
|
||
describe 'SNP API', focus: true do | ||
it 'GET /snps/:id.json' do | ||
create(:snp, name: 'rs1234') | ||
create(:user) { create(:user, name: 'API-Hacker') } | ||
create(:user_snp) {create(:user_snp,user: User.first,snp: Snp.first)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing inside {. |
||
get "/snps/rs1234.json" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
assert_response :success | ||
data = JSON.parse(response.body) | ||
expect(data).to_not be_empty | ||
data = data[0] | ||
%w(name chromosome position).each do |property| | ||
expect(data["snp"].keys).to include(property) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
end | ||
%w(name id genotypes).each do |property| | ||
expect(data["user"].keys).to include(property) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra empty line detected at block body end. |
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Block has too many lines. [34/25]
Missing magic comment # frozen_string_literal: true.