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

ELOSP-770 - Add bbb_override_default_locale metadata #31

Merged
merged 2 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 14 additions & 1 deletion config/initializers/bigbluebutton_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@
record: ability.can?(:record_meeting, room)
}
end


config.get_join_options = Proc.new do |room, user|
if user.present?
# Add custom metadata join calls
include Mconf::LocaleControllerModule
opts = {
# FIXME: remove after team Live update bbb to version 2.4
"userdata-mconf_custom_language": Mconf::LocaleControllerModule.get_user_locale(user),
"userdata-bbb_override_default_locale": Mconf::LocaleControllerModule.get_user_locale(user),
}
opts
end
end

end

Rails.application.config.to_prepare do
Expand Down
2 changes: 1 addition & 1 deletion lib/mconf/locale_controller_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_user_locale(user, use_session=true)
user.locale.to_sym

# session locale
elsif use_session and session_has_locale?(session)
elsif use_session && defined?(session) && session_has_locale?(session)
session[:locale]

# site locale
Expand Down
31 changes: 31 additions & 0 deletions spec/lib/bigbluebutton_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,37 @@
end
end

describe "#get_join_options" do
let(:target) { BigbluebuttonRails.configuration }
let(:room) { FactoryGirl.create(:bigbluebutton_room) }

it { target.should respond_to(:get_join_options) }
it { target.get_create_options.should be_a(Proc) }

context 'sets locale userdata' do
context 'when user has logged in' do
["en", "pt-br"].each do |user_locale|
context "and its locale is set to #{user_locale.upcase}" do
let(:user) { FactoryGirl.create(:user, locale: user_locale) }
let(:join_options) { target.get_join_options.call(room, user, {}) }
let(:locale) { Mconf::LocaleControllerModule.get_user_locale(user) }
# FIXME: remove after team Live update bbb to version 2.4
it { expect(join_options[:"userdata-mconf_custom_language"]).to eql(locale) }
it { expect(join_options[:"userdata-bbb_override_default_locale"]).to eql(locale) }
end
end
end

context 'when user has not logged in' do
let(:join_options) { target.get_join_options.call(room, nil, {}) }
let(:locale) { Mconf::LocaleControllerModule.get_user_locale(nil) }
# FIXME: remove after team Live update bbb to version 2.4
it { expect(join_options).to eql(nil) }
it { expect(join_options).to eql(nil) }
end
end
end

describe "#select_server" do
let(:target) { BigbluebuttonRails.configuration }
let(:room) { FactoryGirl.create(:bigbluebutton_room) }
Expand Down