[MRG] Adding more tests (#390)

* added more tests for snp page

* 🐶  happiness

* tests for changing password

* 🐶  happiness

* helge happiness ;)
This commit is contained in:
Bastian Greshake
2017-06-06 16:16:04 +02:00
committed by GitHub
parent 9499dfc93e
commit 98c1943c1a
2 changed files with 80 additions and 4 deletions

View File

@@ -0,0 +1,45 @@
# frozen_string_literal: true
RSpec.describe 'Password changing' do
let!(:user) { create(:user, name: 'Queen Anne', email: 'anne@the.uk') }
context 'as a signed-in user' do
before do
sign_in(user)
end
scenario 'the password is too short' do
visit "/users/#{user.id}/changepassword"
fill_in('Password', with: '1710')
fill_in('Confirmation', with: '1710')
click_on('Update Information')
expect(page).not_to have_content("Password confirmation doesn't match Password")
expect(page).to have_content('Password is too short')
end
scenario 'confirmation doesnt match' do
visit "/users/#{user.id}/changepassword"
fill_in('Password', with: 'yetanothermary')
fill_in('Confirmation', with: 'yetanothermarry')
click_on('Update Information')
expect(page).to have_content("Password confirmation doesn't match Password")
expect(page).not_to have_content('Password is too short')
end
scenario 'finally got it right' do
visit "/users/#{user.id}/changepassword"
fill_in('Password', with: 'QueenAnnesRevenge')
fill_in('Confirmation', with: 'QueenAnnesRevenge')
click_on('Update Information')
expect(page).not_to have_content("Password confirmation doesn't match Password")
expect(page).not_to have_content('Password is too short')
click_on('Queen Anne')
click_on('Sign out')
visit '/signin'
fill_in('Email', with: 'anne@the.uk')
fill_in('Password', with: 'QueenAnnesRevenge')
click_on('Login')
expect(page).to have_content('Login successful!')
end
end
end

View File

@@ -2,11 +2,42 @@
RSpec.feature 'SNP page' do
let!(:snp) { create(:snp) }
let!(:snpedia_paper) { create(:snpedia_paper, snps: [snp]) }
let!(:user) { create(:user, name: 'Alice') }
let!(:user_snp) do
create(:user_snp, snp: snp, user: user, local_genotype: 'AA')
end
let!(:another_user) { create(:user, name: 'Bob') }
let!(:another_user_snp) do
create(:user_snp, snp: snp, user: another_user, local_genotype: 'TT')
end
scenario 'is requested' do
visit "/snps/#{snp.to_param}"
context 'as a signed-in user' do
before do
sign_in(user)
end
expect(page).to have_content("SNP #{snp.name}")
expect(page).to have_content("#{snp.name} A/C")
scenario 'is requested' do
visit "/snps/#{snp.to_param}"
expect(page).to have_content("SNP #{snp.name}")
expect(page).to have_content("#{snp.name} A/C")
expect(page).to have_content('AA')
end
scenario 'visit index page' do
visit '/snps/'
expect(page).to have_content(snp.name)
end
end
context 'as not signed in user' do
scenario 'is requested' do
visit "/snps/#{snp.to_param}"
expect(page).to have_content("SNP #{snp.name}")
expect(page).to have_content("#{snp.name} A/C")
expect(page).not_to have_content('AA')
end
end
end