Fix subscribing to private channels

This was a combination of 2 bugs:

* we didn't do deep_merge on config in ruby app, so
  that any nested properties set in the javascript app would be
  overwritten
* channelPrefix was not properly set for Travis CI Pro
This commit is contained in:
Piotr Sarnacki 2015-02-25 11:37:21 +01:00
parent 788e624646
commit 7c3ea5b7bc
4 changed files with 16 additions and 2 deletions

View File

@ -39,7 +39,7 @@ TravisPusher.prototype.unsubscribe = (channel) ->
@pusher.unsubscribe(channel) if @pusher?.channel(channel)
TravisPusher.prototype.prefix = (channel) ->
prefix = ENV.pusher.channel_prefix || ''
prefix = ENV.pusher.channelPrefix || ''
if channel.indexOf(prefix) != 0
"#{prefix}#{channel}"
else

View File

@ -42,6 +42,7 @@ module.exports = function(environment) {
ENV.pro = true;
ENV.apiEndpoint = 'https://api.travis-ci.com';
ENV.pusher.key = '59236bc0716a551eab40';
ENV.pusher.channelPrefix = 'private-';
ENV.pagesEndpoint = 'https://billing.travis-ci.com';
ENV.billingEndpoint = 'https://billing.travis-ci.com';
ENV.endpoints = {

View File

@ -0,0 +1,11 @@
module Travis
module DeepMerge
def deep_merge(hash, other_hash)
hash.merge(other_hash) do |key, oldval, newval|
oldval = oldval.to_hash if oldval.respond_to?(:to_hash)
newval = newval.to_hash if newval.respond_to?(:to_hash)
oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? deep_merge(oldval, newval) : newval
end
end
end
end

View File

@ -4,10 +4,12 @@ require 'rack/protection'
require 'delegate'
require 'time'
require 'json'
require 'travis/utils/deep_merge'
class Travis::Web::App
autoload :AltVersions, 'travis/web/app/alt_versions'
autoload :MobileRedirect, 'travis/web/app/mobile_redirect'
include Travis::DeepMerge
S3_URL = 'https://s3.amazonaws.com/travis-web-production/assets'
@ -206,7 +208,7 @@ class Travis::Web::App
string.gsub!(regexp) do
ember_config = JSON.parse(URI.unescape($1))
config = ember_config.merge config
config = deep_merge ember_config, config
config = URI.escape config.to_json
%(<meta name="travis/config/environment" content="#{config}")