e3d86bb21e
Primarily this is in tests (which were caught by temporarily introducing acts_as_tenant and enabling safety checks), but notably action cable connections were not working properly, and that's now fixed.
47 lines
1.4 KiB
Ruby
47 lines
1.4 KiB
Ruby
require "test_helper"
|
|
|
|
class AccountTest < ActiveSupport::TestCase
|
|
test "create" do
|
|
assert_difference "Account::JoinCode.count", +1 do
|
|
Account.create!(name: "ACME corp")
|
|
end
|
|
end
|
|
|
|
test "slug" do
|
|
account = accounts("37s")
|
|
assert_equal "/#{account.external_account_id}", account.slug
|
|
end
|
|
|
|
test ".create_with_admin_user creates a new local account" do
|
|
Current.without_account do
|
|
identity = identities(:david)
|
|
account = nil
|
|
|
|
assert_changes -> { Account.count }, +1 do
|
|
assert_changes -> { User.count }, +2 do
|
|
account = Account.create_with_admin_user(
|
|
account: {
|
|
external_account_id: ActiveRecord::FixtureSet.identify("account-create-with-admin-user-test"),
|
|
name: "Account Create With Admin"
|
|
},
|
|
owner: {
|
|
name: "David",
|
|
identity: identity
|
|
}
|
|
)
|
|
end
|
|
end
|
|
|
|
assert_not_nil account
|
|
assert account.persisted?
|
|
assert_equal ActiveRecord::FixtureSet.identify("account-create-with-admin-user-test"), account.external_account_id
|
|
assert_equal "Account Create With Admin", account.name
|
|
|
|
admin = account.users.find_by(role: "admin")
|
|
assert_equal "David", admin.name
|
|
assert_equal "david@37signals.com", admin.identity.email_address
|
|
assert_equal "admin", admin.role
|
|
end
|
|
end
|
|
end
|