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

[Pre-release] Enable bulk invitations on onboarding step #835

Merged
merged 21 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
9 changes: 9 additions & 0 deletions bin/configure
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ if File.exist?('.github/workflows/main.yml')
File.delete('.github/workflows/main.yml')
end

# Enable the bulk invitations configuration.
bt_config_lines = File.open("config/initializers/bullet_train.rb").readlines
new_lines = bt_config_lines.map do |line|
if line.match?("config.enable_bulk_invitations")
line.gsub!(/#\s*/, "")
end
line
end
File.write("config/initializers/bullet_train.rb", bt_config_lines.join)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


puts "Next, let's push your application to GitHub."
puts "If you would like to use another service like Gitlab to manage your repository,"
Expand Down
3 changes: 3 additions & 0 deletions config/initializers/bullet_train.rb
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
14 changes: 13 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/system/account_management_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AccountManagementSystemTest < ApplicationSystemTestCase
fill_in "Your Team Name", with: "The Testing Team"
page.select "Brisbane", from: "Your Time Zone"
click_on "Next"
click_on "Skip" if bulk_invitations_enabled?

if billing_enabled?
unless freemium_enabled?
Expand Down
1 change: 1 addition & 0 deletions test/system/application_platform_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ApplicationPlatformSystemTest < ApplicationSystemTestCase
fill_in "Last Name", with: "Smith"
fill_in "Your Team Name", with: "The Testing Team"
click_on "Next"
click_on "Skip" if bulk_invitations_enabled?

if billing_enabled?
unless freemium_enabled?
Expand Down
1 change: 1 addition & 0 deletions test/system/authentication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class AuthenticationSystemTest < ApplicationSystemTestCase
fill_in "Last Name", with: "McTesterson"
fill_in "Your Team Name", with: "The Testing Team"
click_on "Next"
click_on "Skip" if bulk_invitations_enabled?

if billing_enabled?
unless freemium_enabled?
Expand Down
1 change: 1 addition & 0 deletions test/system/dates_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class DatesHelperTest < ApplicationSystemTestCase
fill_in "Your Team Name", with: "The Testing Team"
select "(GMT+00:00) UTC", from: "Your Time Zone"
click_on "Next"
click_on "Skip" if bulk_invitations_enabled?

if billing_enabled?
unless freemium_enabled?
Expand Down
1 change: 1 addition & 0 deletions test/system/fields_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AccountTest < ApplicationSystemTestCase
fill_in "Your Team Name", with: "My Super Team"
page.select "Brisbane", from: "Your Time Zone"
click_on "Next"
click_on "Skip" if bulk_invitations_enabled?

if billing_enabled?
unless freemium_enabled?
Expand Down
64 changes: 64 additions & 0 deletions test/system/invitation_lists_test.rb
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?
Copy link
Contributor

Choose a reason for hiding this comment

The 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
2 changes: 2 additions & 0 deletions test/system/invitations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class InvitationDetailsTest < ApplicationSystemTestCase
fill_in "Last Name", with: "Tanaka"
fill_in "Your Team Name", with: "The Testing Team"
click_on "Next"
click_on "Skip" if bulk_invitations_enabled?

if billing_enabled?
unless freemium_enabled?
Expand Down Expand Up @@ -177,6 +178,7 @@ class InvitationDetailsTest < ApplicationSystemTestCase
fill_in "First Name", with: "Taka"
fill_in "Last Name", with: "Yamaguchi"
click_on "Next"
click_on "Skip" if bulk_invitations_enabled?

assert page.has_content?("The Testing Team’s Dashboard")
within_team_menu_for(display_details) do
Expand Down
1 change: 1 addition & 0 deletions test/system/membership_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class MembershipSystemTest < ApplicationSystemTestCase
fill_in "Last Name", with: "Smith"
fill_in "Your Team Name", with: "The Testing Team"
click_on "Next"
click_on "Skip" if bulk_invitations_enabled?

if billing_enabled?
unless freemium_enabled?
Expand Down
1 change: 1 addition & 0 deletions test/system/reactivity_system_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ReactivitySystemTest < ApplicationSystemTestCase
fill_in "Your Team Name", with: "My Super Team"
page.select "Brisbane", from: "Your Time Zone"
click_on "Next"
click_on "Skip" if bulk_invitations_enabled?

if billing_enabled?
unless freemium_enabled?
Expand Down
1 change: 1 addition & 0 deletions test/system/tangible_thing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TangibleThingTest < ApplicationSystemTestCase
fill_in "Your Team Name", with: "My Super Team"
page.select "Brisbane", from: "Your Time Zone"
click_on "Next"
click_on "Skip" if bulk_invitations_enabled?

if billing_enabled?
unless freemium_enabled?
Expand Down