Update tests for users who enable NO_EMAILS

pull/496/head
Rick Carlino 2017-10-11 10:45:34 -05:00
parent 2dfb3ca94f
commit f31a3bd84f
2 changed files with 22 additions and 16 deletions

View File

@ -138,17 +138,20 @@ describe Api::UsersController do
expect(json[:user])
.to include(Users::ResendVerification::ALREADY_VERIFIED)
end
unless ENV["NO_EMAILS"]
it 're-sends verification email' do
unverified = User.create!(email: Faker::Internet.email,
password: "password123",
password_confirmation: "password123")
it 're-sends verification email' do
unverified = User.create!(email: Faker::Internet.email,
password: "password123",
password_confirmation: "password123")
post :resend_verification,
params: { email: unverified.email },
format: :json
post :resend_verification,
params: { email: unverified.email },
format: :json
expect(response.status).to eq(200)
expect(json[:user]).to include(Users::ResendVerification::SENT)
expect(response.status).to eq(200)
expect(json[:user]).to include(Users::ResendVerification::SENT)
end
else
puts "Skipping test because NO_EMAILS was enabled."
end
end

View File

@ -40,11 +40,14 @@ describe SessionToken do
expect(result.success?).to be(false)
expect(result.errors.values.first.message).to include("is not valid")
end
it "doesn't mint tokens for unverified users" do
user.update_attributes!(verified_at: nil)
expect {
SessionToken.issue_to(user, iat: 000, exp: 1, iss: "//lycos.com:9867")
}.to raise_error(Errors::Forbidden)
unless ENV["NO_EMAILS"]
it "doesn't mint tokens for unverified users" do
user.update_attributes!(verified_at: nil)
expect {
SessionToken.issue_to(user, iat: 000, exp: 1, iss: "//lycos.com:9867")
}.to raise_error(Errors::Forbidden)
end
else
puts "Skipping a test because NO_EMAILS was enabled."
end
end