Require valid invitation to start sign-up process
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
7
spec/factories/invitations.rb
Normal file
7
spec/factories/invitations.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory :invitation do
|
||||
id { 1 }
|
||||
token { "abcdef123456" }
|
||||
user
|
||||
end
|
||||
end
|
||||
39
spec/features/signup_spec.rb
Normal file
39
spec/features/signup_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Signup", type: :feature do
|
||||
let(:user) { create :user }
|
||||
|
||||
before do
|
||||
@unused_invitation = Invitation.create(user: user)
|
||||
@used_invitation = Invitation.create(user: user)
|
||||
@used_invitation.update_attribute :used_at, DateTime.now - 1.day
|
||||
end
|
||||
|
||||
scenario "Follow link for non-existing invitation" do
|
||||
visit invitation_url(id: "123")
|
||||
|
||||
within ".flash-msg.alert" do
|
||||
expect(page).to have_content("doesn't exist")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Follow link for used invitation" do
|
||||
visit invitation_url(id: @used_invitation.token)
|
||||
|
||||
within ".flash-msg.alert" do
|
||||
expect(page).to have_content("has already been used")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Follow link for unused invitation" do
|
||||
visit invitation_url(id: @unused_invitation.token)
|
||||
|
||||
expect(current_url).to eq(signup_url)
|
||||
expect(page).to have_content("Welcome")
|
||||
end
|
||||
|
||||
scenario "Successful signup" do
|
||||
visit invitation_url(id: @unused_invitation.token)
|
||||
click_link "Get started"
|
||||
end
|
||||
end
|
||||
15
spec/helpers/signup_helper_spec.rb
Normal file
15
spec/helpers/signup_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the SignupHelper. For example:
|
||||
#
|
||||
# describe SignupHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe SignupHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -20,4 +20,12 @@ RSpec.describe User, type: :model do
|
||||
expect(user.is_admin?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#address" do
|
||||
let(:user) { build :user, cn: "jimmy", ou: "kosmos.org" }
|
||||
|
||||
it "returns the user address" do
|
||||
expect(user.address).to eq("jimmy@kosmos.org")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
14
spec/requests/signup_request_spec.rb
Normal file
14
spec/requests/signup_request_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Signups", type: :request do
|
||||
|
||||
describe "GET /index" do
|
||||
context "without invitation" do
|
||||
it "returns http unauthorized" do
|
||||
get "/signup"
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user