From 56a72ade9d3844933e4819886bd5241b68f0c099 Mon Sep 17 00:00:00 2001
From: Jesus Federico <jesus@123it.ca>
Date: Fri, 18 Jan 2019 10:29:06 -0500
Subject: [PATCH] Completed fix for the specs (#343)

---
 config/application.rb    |  8 ++++----
 spec/models/room_spec.rb | 10 +++++++---
 spec/spec_helper.rb      |  4 ++--
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/config/application.rb b/config/application.rb
index 1b26ca66..ca9496a2 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -47,6 +47,10 @@ module Greenlight
     # The default callback url that bn launcher will redirect to
     config.gl_callback_url = ENV["GL_CALLBACK_URL"]
 
+    # Default credentials (test-install.blindsidenetworks.com/bigbluebutton).
+    config.bigbluebutton_endpoint_default = "http://test-install.blindsidenetworks.com/bigbluebutton/api/"
+    config.bigbluebutton_secret_default = "8cd8ef52e8e101574e400365b55e11a6"
+
     # Setup BigBlueButton configuration.
     if config.loadbalanced_configuration
       # Fetch credentials from a loadbalancer based on provider.
@@ -54,10 +58,6 @@ module Greenlight
       config.loadbalancer_secret = ENV["LOADBALANCER_SECRET"]
       config.launcher_secret = ENV["LAUNCHER_SECRET"]
     else
-      # Default credentials (test-install.blindsidenetworks.com/bigbluebutton).
-      config.bigbluebutton_endpoint_default = "http://test-install.blindsidenetworks.com/bigbluebutton/api/"
-      config.bigbluebutton_secret_default = "8cd8ef52e8e101574e400365b55e11a6"
-
       # Use standalone BigBlueButton server.
       config.bigbluebutton_endpoint = ENV["BIGBLUEBUTTON_ENDPOINT"] || config.bigbluebutton_endpoint_default
       config.bigbluebutton_secret = ENV["BIGBLUEBUTTON_SECRET"] || config.bigbluebutton_secret_default
diff --git a/spec/models/room_spec.rb b/spec/models/room_spec.rb
index 3aecd981..b2d2f4e6 100644
--- a/spec/models/room_spec.rb
+++ b/spec/models/room_spec.rb
@@ -91,8 +91,13 @@ describe Room, type: :model do
         attendeePW: "testpass"
       )
 
-      endpoint = Rails.configuration.bigbluebutton_endpoint
-      secret = Rails.configuration.bigbluebutton_secret
+      if Rails.configuration.loadbalanced_configuration
+        endpoint = Rails.configuration.loadbalancer_endpoint
+        secret = Rails.configuration.loadbalancer_secret
+      else
+        endpoint = Rails.configuration.bigbluebutton_endpoint
+        secret = Rails.configuration.bigbluebutton_secret
+      end
       fullname = "fullName=Example"
       meeting_id = "&meetingID=#{@room.bbb_id}"
       password = "&password=testpass"
@@ -101,7 +106,6 @@ describe Room, type: :model do
       checksum_string = "join#{query + secret}"
 
       checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack("H*").first
-
       expect(@room.join_path("Example")).to eql("#{endpoint}join?#{query}&checksum=#{checksum}")
     end
   end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 17a3ad99..e085ae1f 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -83,8 +83,8 @@ RSpec.configure do |config|
           <user>
             <name>greenlight</name>
             <maxMeetings>1000</maxMeetings>
-            <apiURL>#{ENV['LOADBALANCER_ENDPOINT'] + 'api'}</apiURL>
-            <secret>#{ENV['BIGBLUEBUTTON_SECRET']}</secret>
+            <apiURL>#{ENV['LOADBALANCER_ENDPOINT']}</apiURL>
+            <secret>#{ENV['LOADBALANCER_SECRET']}</secret>
           </user>
         </response>", headers: {}) if ENV['LOADBALANCER_ENDPOINT']
   end
-- 
GitLab