Skip to content
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

Merged
merged 4 commits into from Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 0 additions & 28 deletions spec/features/arriving_as_user.rb

This file was deleted.

40 changes: 40 additions & 0 deletions spec/features/login_spec.rb
@@ -0,0 +1,40 @@
RSpec.describe 'Arriving at openSNP' do
Copy link
Collaborator

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.

let!(:user) { create(:user, name: 'Potato Bill', email: 'potato@example.com')}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing inside }.

let!(:phenotype) {create(:phenotype, characteristic: 'Eye color')}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing inside {.
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
22 changes: 22 additions & 0 deletions spec/requests/snps_spec.rb
@@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'spec_helper'
Copy link
Collaborator

Choose a reason for hiding this comment

The 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)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing inside {.
Space missing after comma.
Space missing inside }.

get "/snps/rs1234.json"
Copy link
Collaborator

Choose a reason for hiding this comment

The 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The 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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body end.

end
end