-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
[Pre-release] Enable bulk invitations on onboarding step #835
Changes from 11 commits
8fe9620
747b2fc
a7da933
0ae8bed
2355350
232bdaa
8bafc6b
70d72cd
25f4dac
bc794d5
723ce1f
0371ca2
c629877
811fec2
42d8cc9
61ad1f5
99fc86d
3f40455
b81488d
22eef51
9de755e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
BulletTrain.configure do |config| | ||
# Uncomment this line if you want to bypass strong passwords. | ||
# config.strong_passwords = false | ||
|
||
# Enable bulk invitations on the user onboarding step. | ||
# config.enable_bulk_invitations = true | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateAccountOnboardingInvitationLists < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :account_onboarding_invitation_lists do |t| | ||
t.references :team, null: false, foreign_key: true | ||
t.jsonb :invitations | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddInvitationListToInvitations < ActiveRecord::Migration[7.0] | ||
def change | ||
add_reference :invitations, :invitation_list, null: true, foreign_key: {to_table: :account_onboarding_invitation_lists} | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require "application_system_test_case" | ||
|
||
class InvitationListsTest < ApplicationSystemTestCase | ||
if bulk_invitations_enabled? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test isn't running because we default to this feature being turned off. I think this test should change the config setting prior to test setup to ensure that this test always run. (And it should restore the original setting afterwards.) |
||
@@test_devices.each do |device_name, display_details| | ||
test "visitors can send bulk invitations upon signing up" do | ||
resize_for(display_details) | ||
|
||
sign_up_from_homepage_for(display_details) | ||
fill_in "Your Email Address", with: "[email protected]" | ||
fill_in "Set Password", with: example_password | ||
fill_in "Confirm Password", with: example_password | ||
click_on "Sign Up" | ||
|
||
assert page.has_content?("Tell us about you") | ||
fill_in "First Name", with: "Hanako" | ||
fill_in "Last Name", with: "Tanaka" | ||
fill_in "Your Team Name", with: "The Testing Team" | ||
click_on "Next" | ||
|
||
if billing_enabled? | ||
unless freemium_enabled? | ||
complete_pricing_page | ||
end | ||
end | ||
|
||
# Click on next to show that bulk invitations will raise an error if not filled out properly. | ||
click_on "Next" | ||
assert page.has_content?("Please correct the errors below.") | ||
assert page.has_content?("Invitations email can't be blank") | ||
|
||
# Fill in the email addresses. | ||
email_fields = page.all("label", text: "Email Address") | ||
email_fields.each_with_index do |field, idx| | ||
field.sibling("div").find("input").fill_in with: "test-#{idx}@some-company.com" | ||
end | ||
|
||
# Select roles from select element. | ||
role_ids = ["Default", "Editor", "Admin"] | ||
role_fields = page.all("label", text: "Role ids") | ||
role_fields.each_with_index do |role_field, idx| | ||
select_field = role_field.sibling("div").find("select") | ||
select_field.all("option").find { |opt| opt.text == role_ids[idx] }.select_option | ||
end | ||
|
||
assert_difference(["Invitation.count", "Membership.count"], 3) do | ||
click_on "Next" | ||
sleep 2 | ||
end | ||
|
||
assert page.has_content?("The Testing Team’s Dashboard") | ||
within_team_menu_for(display_details) do | ||
click_on "Team Members" | ||
end | ||
|
||
3.times do |idx| | ||
assert page.has_content?("test-#{idx}@some-company.com") | ||
invitation = Invitation.find_by(email: "test-#{idx}@some-company.com") | ||
assert_equal invitation.membership.role_ids, [role_ids[idx].downcase] | ||
end | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!