Permalink
Browse files

Prepend Gosen::VERSION to the User-Agent instead of building it from …

…scratch
  • Loading branch information...
1 parent 991d167 commit 4b40dc3b334f8bec2df231291a9b02538ae434de @priteau committed Oct 26, 2010
Showing with 3 additions and 1 deletion.
  1. +2 −1 lib/gosen/deployment.rb
  2. +1 −0 test/gosen/test_deployment.rb
View
@@ -23,7 +23,8 @@ def initialize(site, environment, nodes, options = {})
@api_options = {}
@logger = options.delete(:logger) || NullLogger.new
- @site.session.default_headers['User-Agent'] = "Gosen/#{Gosen::VERSION} Restfully/#{Restfully::VERSION}"
+ user_agent = @site.session.default_headers['User-Agent']
+ @site.session.default_headers['User-Agent'] = "Gosen/#{Gosen::VERSION} #{user_agent}" unless user_agent =~ /^Gosen\/#{Gosen::VERSION}/
@min_deployed_nodes = options.delete(:min_deployed_nodes) || 1
raise Gosen::Error.new("Invalid minimal number of deployed nodes, should be between 0 and #{@nodes.length}") if @min_deployed_nodes > @nodes.length || @min_deployed_nodes < 0
@@ -6,6 +6,7 @@ class TestDeployment < Test::Unit::TestCase
@site = mock()
@session = mock()
@default_headers = mock()
+ @default_headers.stubs(:[]).with('User-Agent').returns("Restfully/#{Restfully::VERSION}")
@default_headers.stubs(:[]=).with('User-Agent', "Gosen/#{Gosen::VERSION} Restfully/#{Restfully::VERSION}")
@session.stubs(:default_headers).returns(@default_headers)
@site.stubs(:session).returns(@session)

0 comments on commit 4b40dc3

Please sign in to comment.