Skip to content

Commit

Permalink
remove branching on Rails.env for faye urls
Browse files Browse the repository at this point in the history
  • Loading branch information
oponder committed Mar 13, 2013
1 parent 74967a7 commit c592bef
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
@@ -1,11 +1,10 @@
class Kandan.Broadcasters.FayeBroadcaster

constructor: ()->
@fayeClient = new Faye.Client("http://<%= ActionMailer::Base.default_url_options[:host] %>/remote/faye")

<% if Rails.env == "test" %>
@fayeClient = new Faye.Client("http://localhost:9292/remote/faye")
@fayeClient.setHeader('Access-Control-Allow-Origin', '*');
<% else %>
@fayeClient = new Faye.Client("/remote/faye")
<% end %>

@fayeClient.disable('websocket')
Expand Down
3 changes: 2 additions & 1 deletion config/environments/development.rb
Expand Up @@ -39,5 +39,6 @@
config.logger.level = Logger.const_get(
ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'DEBUG'
)


config.action_mailer.default_url_options = { :host => "localhost:3000" }
end
2 changes: 2 additions & 0 deletions config/environments/test.rb
Expand Up @@ -34,4 +34,6 @@

# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr

config.action_mailer.default_url_options = { :host => "localhost:9292" }
end
6 changes: 1 addition & 5 deletions lib/broadcasters/faye.rb
Expand Up @@ -13,11 +13,7 @@ def broadcast(channel, message)
end

def assets
if Rails.env == "test"
["http://localhost:9292/remote/faye.js"]
else
['remote/faye']
end
["http://#{ActionMailer::Base.default_url_options[:host]}/remote/faye.js"]
end
end
end
Expand Down

0 comments on commit c592bef

Please sign in to comment.