restrict user invites
This commit is contained in:
committed by
Pete Matsyburka
parent
b317094192
commit
b6a2aae970
@@ -6,6 +6,10 @@ FactoryBot.define do
|
||||
locale { 'en-US' }
|
||||
timezone { 'UTC' }
|
||||
|
||||
transient do
|
||||
teams_count { 2 }
|
||||
end
|
||||
|
||||
trait :with_testing_account do
|
||||
after(:create) do |account|
|
||||
testing_account = account.dup.tap { |a| a.name = "Testing - #{account.name}" }
|
||||
@@ -14,5 +18,16 @@ FactoryBot.define do
|
||||
account.save!
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_teams do
|
||||
after(:create) do |account, evaluator|
|
||||
Array.new(evaluator.teams_count) do |i|
|
||||
Account.create!(
|
||||
name: "Team #{i}",
|
||||
linked_account_account: AccountLinkedAccount.new(account_type: :linked, account:)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,6 +68,10 @@ RSpec.configure do |config|
|
||||
config.before do |example|
|
||||
Sidekiq::Testing.inline! if example.metadata[:sidekiq] == :inline
|
||||
end
|
||||
|
||||
config.before(multitenant: true) do
|
||||
allow(Docuseal).to receive(:multitenant?).and_return(true)
|
||||
end
|
||||
end
|
||||
|
||||
ActiveSupport.run_load_hooks(:rails_specs, self)
|
||||
|
||||
@@ -4,6 +4,7 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Team Settings' do
|
||||
let(:account) { create(:account) }
|
||||
let(:second_account) { create(:account) }
|
||||
let(:current_user) { create(:user, account:) }
|
||||
|
||||
before do
|
||||
@@ -56,6 +57,43 @@ RSpec.describe 'Team Settings' do
|
||||
end
|
||||
end
|
||||
|
||||
it "doesn't create a new user if a user already exists" do
|
||||
click_link 'New User'
|
||||
|
||||
within '#modal' do
|
||||
fill_in 'First name', with: 'Michael'
|
||||
fill_in 'Last name', with: 'Jordan'
|
||||
fill_in 'Email', with: users.first.email
|
||||
fill_in 'Password', with: 'password'
|
||||
|
||||
expect do
|
||||
click_button 'Submit'
|
||||
end.not_to change(User, :count)
|
||||
end
|
||||
|
||||
expect(page).to have_content('Email already exists')
|
||||
end
|
||||
|
||||
it "doesn't create a new user if a user belongs to another account" do
|
||||
user = create(:user, account: second_account)
|
||||
visit settings_users_path
|
||||
|
||||
click_link 'New User'
|
||||
|
||||
within '#modal' do
|
||||
fill_in 'First name', with: 'Michael'
|
||||
fill_in 'Last name', with: 'Jordan'
|
||||
fill_in 'Email', with: user.email
|
||||
fill_in 'Password', with: 'password'
|
||||
|
||||
expect do
|
||||
click_button 'Submit'
|
||||
end.not_to change(User, :count)
|
||||
|
||||
expect(page).to have_content('Email has already been taken')
|
||||
end
|
||||
end
|
||||
|
||||
it 'updates a user' do
|
||||
first(:link, 'Edit').click
|
||||
|
||||
|
||||
Reference in New Issue
Block a user