Skip to content

Commit

Permalink
Setup Heroku review app (#89)
Browse files Browse the repository at this point in the history
Setup review app for smoke test purposes.

Eventually we would want to setup review app for system test purposes but that would require us to automatically setup convene-pr-xxx.zinc.coop per review app.
  • Loading branch information
user512 committed Aug 13, 2020
1 parent 18c37b7 commit 64cf9dd
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app.json
@@ -0,0 +1,32 @@
{
"name": "Convene Web Heroku Review App Configuration",
"env": {
"APP_BASE": {
"description": "Relative path for Convene Web, consume by Heroku mono repo buildpack",
"value": "convene-web"
},
"SYSTEM_TEST": {
"description": "Seed system test data",
"value": "true"
}
},
"buildpacks": [
{
"url": "https://github.com/lstoll/heroku-buildpack-monorepo"
},
{
"url": "https://github.com/heroku/heroku-buildpack-ruby"
}
],
"addons": [
{
"plan": "heroku-postgresql:hobby-dev",
"options": {
"version": "12"
}
}
],
"scripts": {
"postdeploy": "bundle exec rails db:seed"
}
}
1 change: 1 addition & 0 deletions convene-web/app/models/feature.rb
Expand Up @@ -6,6 +6,7 @@ class Feature
def self.enabled?(feature)
feature = feature.to_sym if feature.respond_to?(:to_sym)
return true if feature == :demo && ENV['DEMO_ENABLED']
return true if feature == :system_test && ENV['SYSTEM_TEST']

false
end
Expand Down
58 changes: 58 additions & 0 deletions convene-web/app/models/system_test_workspace.rb
@@ -0,0 +1,58 @@
class SystemTestWorkspace
# Creates the system test workspace, but only on environments which are
# configured to include the system test workspace.
def self.prepare
return unless Feature.enabled?(:system_test)

Factory.new(Client).find_or_create_workspace!
end

class Factory
attr_accessor :client_repository
# Expand this to include more room types for different test cases
DEMO_ROOMS = [
{
name: "Listed Room 1",
publicity_level: :listed,
},
{
name: "Listed Room 2",
publicity_level: :listed,
},
{
name: "Unlisted Room 1",
publicity_level: :unlisted,
},
{
name: "Unlisted Room 2",
publicity_level: :unlisted,
},
].freeze

# @param [ActiveRecord::Relation<Client>] client_repository Where to ensure there
# is a Zinc Client with the Convene Demo workspace
def initialize(client_repository)
self.client_repository = client_repository
end

def find_or_create_workspace!
workspace = client.workspaces.find_or_create_by!(name: 'System Test')
workspace.update!(jitsi_meet_domain: 'convene-videobridge-zinc.zinc.coop',
branded_domain: "#{ENV.fetch('HEROKU_APP_NAME')}.herokuapp.com",
access_level: :unlocked)
add_demo_rooms(workspace)
workspace
end

private def add_demo_rooms(workspace)
DEMO_ROOMS.each do |room|
workspace.rooms.find_or_create_by!(name: room[:name], publicity_level: room[:publicity_level])
end
workspace
end

private def client
@_client ||= client_repository.find_or_create_by!(name: 'Zinc')
end
end
end
1 change: 1 addition & 0 deletions convene-web/db/seeds.rb
Expand Up @@ -29,3 +29,4 @@
ttz.owners << zee

DemoWorkspace.prepare
SystemTestWorkspace.prepare

0 comments on commit 64cf9dd

Please sign in to comment.