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 all 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
10 changes: 10 additions & 0 deletions bin/configure
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ else
exit
end

# TODO: Uncomment this when the enable bulk invitations JS is implemented.
# 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)

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
Expand Up @@ -2,6 +2,9 @@
# 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

# Change the parent class you want incoming webhooks to inherit from.
config.incoming_webhooks_parent_class_name = "ApplicationRecord"
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
73 changes: 73 additions & 0 deletions test/system/invitation_lists_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
require "application_system_test_case"

class InvitationListsTest < ApplicationSystemTestCase
@@test_devices.each do |device_name, display_details|
def setup
@current_bulk_invitations_setting = nil
BulletTrain.configure do |config|
@current_bulk_invitations_setting = config.enable_bulk_invitations
config.enable_bulk_invitations = true
end
end

def teardown
BulletTrain.configure do |config|
config.enable_bulk_invitations = @current_bulk_invitations_setting
end
end

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?("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_fields = page.all("label", text: "Role")
role_fields.each do |role_field|
select_field = role_field.sibling("div").find("select")
select_field.select "admin"
select_field.select "editor"
end

assert_difference(["Invitation.count", "Membership.count"], 1) 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

assert page.has_content?("[email protected]")
invitation = Invitation.find_by(email: "[email protected]")
assert_equal invitation.membership.role_ids, ["admin", "editor"]
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_text("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
Loading