Add feature spec for whole signup process
This commit is contained in:
parent
2a2b0a90dc
commit
022094ce51
@ -3,6 +3,7 @@ require "rails_helper"
|
|||||||
RSpec.describe "Signup", type: :feature do
|
RSpec.describe "Signup", type: :feature do
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
|
|
||||||
|
describe "Invitation handling" do
|
||||||
before do
|
before do
|
||||||
@unused_invitation = Invitation.create(user: user)
|
@unused_invitation = Invitation.create(user: user)
|
||||||
@used_invitation = Invitation.create(user: user)
|
@used_invitation = Invitation.create(user: user)
|
||||||
@ -31,9 +32,72 @@ RSpec.describe "Signup", type: :feature do
|
|||||||
expect(current_url).to eq(signup_url)
|
expect(current_url).to eq(signup_url)
|
||||||
expect(page).to have_content("Welcome")
|
expect(page).to have_content("Welcome")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Successful signup" do
|
describe "Signup steps" do
|
||||||
visit invitation_url(id: @unused_invitation.token)
|
before do
|
||||||
|
@invitation = Invitation.create(user: user)
|
||||||
|
visit invitation_url(id: @invitation.token)
|
||||||
click_link "Get started"
|
click_link "Get started"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Successful signup (happy path galore)" do
|
||||||
|
expect(page).to have_content("Choose a username")
|
||||||
|
|
||||||
|
fill_in "user_cn", with: "tony"
|
||||||
|
click_button "Continue"
|
||||||
|
expect(page).to have_content("What's your email?")
|
||||||
|
|
||||||
|
fill_in "user_email", with: "tony@example.com"
|
||||||
|
click_button "Continue"
|
||||||
|
expect(page).to have_content("Choose a password")
|
||||||
|
|
||||||
|
expect(CreateAccount).to receive(:call)
|
||||||
|
.with(username: "tony", email: "tony@example.com", password: "a-valid-password")
|
||||||
|
.and_return(true)
|
||||||
|
|
||||||
|
fill_in "user_password", with: "a-valid-password"
|
||||||
|
click_button "Create account"
|
||||||
|
within ".flash-msg.notice" do
|
||||||
|
expect(page).to have_content("confirm your address")
|
||||||
|
end
|
||||||
|
expect(page).to have_content("close this window or tab now")
|
||||||
|
expect(User.last.confirmed_at).to be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Validation errors" do
|
||||||
|
fill_in "user_cn", with: "t"
|
||||||
|
click_button "Continue"
|
||||||
|
expect(page).to have_content("Username is too short")
|
||||||
|
fill_in "user_cn", with: "jimmy"
|
||||||
|
click_button "Continue"
|
||||||
|
expect(page).to have_content("Username has already been taken")
|
||||||
|
fill_in "user_cn", with: "tony"
|
||||||
|
click_button "Continue"
|
||||||
|
|
||||||
|
fill_in "user_email", with: "tony@"
|
||||||
|
click_button "Continue"
|
||||||
|
expect(page).to have_content("Email is not a valid address")
|
||||||
|
fill_in "user_email", with: ""
|
||||||
|
click_button "Continue"
|
||||||
|
expect(page).to have_content("Email can't be blank")
|
||||||
|
fill_in "user_email", with: "tony@example.com"
|
||||||
|
click_button "Continue"
|
||||||
|
|
||||||
|
fill_in "user_password", with: "123456"
|
||||||
|
click_button "Create account"
|
||||||
|
expect(page).to have_content("Password is too short")
|
||||||
|
|
||||||
|
expect(CreateAccount).to receive(:call)
|
||||||
|
.with(username: "tony", email: "tony@example.com", password: "a-valid-password")
|
||||||
|
.and_return(true)
|
||||||
|
|
||||||
|
fill_in "user_password", with: "a-valid-password"
|
||||||
|
click_button "Create account"
|
||||||
|
within ".flash-msg.notice" do
|
||||||
|
expect(page).to have_content("confirm your address")
|
||||||
|
end
|
||||||
|
expect(User.last.cn).to eq("tony")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user