Browse Source

Email is unique

pull/109/head
baarkerlounger 4 years ago
parent
commit
49d5e86263
  1. 2
      spec/factories/admin_user.rb
  2. 2
      spec/factories/user.rb
  3. 10
      spec/features/user_spec.rb

2
spec/factories/admin_user.rb

@ -1,6 +1,6 @@
FactoryBot.define do
factory :admin_user do
email { "admin@example.com" }
sequence(:email) { |i| "admin#{i}@example.com" }
password { "pAssword1" }
created_at { Time.zone.now }
updated_at { Time.zone.now }

2
spec/factories/user.rb

@ -1,6 +1,6 @@
FactoryBot.define do
factory :user do
email { "test@example.com" }
sequence(:email) { |i| "test#{i}@example.com" }
password { "pAssword1" }
created_at { Time.zone.now }
updated_at { Time.zone.now }

10
spec/features/user_spec.rb

@ -9,7 +9,7 @@ RSpec.describe "User Features" do
it " is redirected to case logs after signing in" do
visit("/case_logs")
fill_in("user_email", with: "test@example.com")
fill_in("user_email", with: user.email)
fill_in("user_password", with: "pAssword1")
click_button("Sign in")
expect(page).to have_current_path("/case_logs")
@ -25,16 +25,16 @@ RSpec.describe "User Features" do
it " is redirected to check your email page after submitting an email on the reset password page" do
visit("/users/password/new")
fill_in("user_email", with: "test@example.com")
fill_in("user_email", with: user.email)
click_button("Send email")
expect(page).to have_content("Check your email")
end
it " is shown their email on the password reset confirmation page" do
visit("/users/password/new")
fill_in("user_email", with: "test@example.com")
fill_in("user_email", with: user.email)
click_button("Send email")
expect(page).to have_content("test@example.com")
expect(page).to have_content(user.email)
end
it " is shown the reset password confirmation page even if their email doesn't exist in the system" do
@ -46,7 +46,7 @@ RSpec.describe "User Features" do
it " is sent a reset password email" do
visit("/users/password/new")
fill_in("user_email", with: "test@example.com")
fill_in("user_email", with: user.email)
expect { click_button("Send email") }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end

Loading…
Cancel
Save