Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create and access multiple accounts #720

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions app/views/layouts/_menu.slim
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
ul.nav.navbar-nav.navbar-right
- if current_user.nil? && current_account.nil?
- if current_user.nil?
li= link_to 'Sign in', new_session_path
- else
li.dropdown
a.apps-list.dropdown-toggle data-toggle="dropdown" href="#"
' Signed in as
b = current_user&.name || current_user&.email || 'heroku admin'
b= current_user.name || current_user.email
b.caret<
ul.dropdown-menu.accounts-menu
li
a Loading...
ul.dropdown-menu
- current_user.accounts.each do |account|
li= link_to account.name, switch_account_session_path(account_id: account.id)
- if admin?
li= link_to 'New database connection', new_account_path
li.divider
- if admin? && current_account
li= link_to 'Account settings', edit_account_path
li= link_to 'Roles and permissions', roles_path
li= link_to 'Collaborators', collaborators_path
li= link_to 'Sign out', signout_path
li.dropdown
a.dropdown-toggle data-toggle="dropdown" href="#"
i.fa.fa-question-circle
ul.dropdown-menu
li= link_to 'Docs', docs_path
li= link_to 'Docs', docs_path
31 changes: 30 additions & 1 deletion test/integration/setup_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'test_helper'

class SetupTest < ActionDispatch::IntegrationTest
test 'sign up and setup account' do
test 'sign up and setup account then invite collaborators' do
add_virtual_authenticator
visit root_path
click_on 'Sign up'
Expand Down Expand Up @@ -67,6 +67,35 @@ class SetupTest < ActionDispatch::IntegrationTest
end
end

test 'sign up and setup two accounts' do
add_virtual_authenticator
visit root_path
click_on 'Sign up'
fill_in 'Email', with: '[email protected]'
click_on 'Sign up'
fill_in 'Database name', with: 'adminium-fixture'
click_on 'Create'
fill_in 'postgresql://user:password@host/database', with: Rails.configuration.test_database_conn_spec
click_on 'Connect'
click_on 'Close'
assert has_link?('comments')
click_on 'Signed in as [email protected]'
click_on 'New database connection'
fill_in 'Database name', with: 'adminium-test'
click_on 'Create'
spec = ActiveRecord::Base.connection_db_config.configuration_hash
url ="#{spec[:adapter]}://#{spec[:username]}:#{spec[:password]}@#{spec[:host]}/#{spec[:database]}"
fill_in 'postgresql://user:password@host/database', with: url
click_on 'Connect'
click_on 'Close'
assert has_link?('accounts')
assert has_no_link?('comments')
click_on 'Signed in as [email protected]'
click_on 'adminium-fixture'
assert has_link?('comments')
assert has_no_link?('accounts')
end

def add_virtual_authenticator
options = { protocol: :ctap2, transport: :internal, hasResidentKey: false, hasUserVerification: true, isUserVerified: true }
page.driver.browser.add_virtual_authenticator options
Expand Down